@michengai/dsh-codex-ui 0.2.68 → 0.2.70

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.
package/README.md CHANGED
@@ -12,6 +12,7 @@
12
12
 
13
13
  [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](LICENSE)
14
14
  [![npm package](https://img.shields.io/npm/v/%40michengai%2Fdsh-codex-ui.svg?label=npm%20package)](https://www.npmjs.com/package/@michengai/dsh-codex-ui)
15
+ [![npm downloads](https://img.shields.io/npm/dt/%40michengai%2Fdsh-codex-ui.svg?label=npm%20downloads&v=2)](https://www.npmjs.com/package/@michengai/dsh-codex-ui)
15
16
  [![DSH Web Plugin](https://img.shields.io/badge/DSH%20Web-Plugin-0f766e.svg)](https://github.com/MichengAI/dsh-codex-ui)
16
17
  [![Node.js 22 or later](https://img.shields.io/badge/Node.js-22%20or%20later-339933.svg?logo=node.js&logoColor=white)](https://nodejs.org/)
17
18
 
package/README.zh-CN.md CHANGED
@@ -12,6 +12,7 @@
12
12
 
13
13
  [![许可证:Apache-2.0](https://img.shields.io/badge/许可证-Apache--2.0-blue.svg)](LICENSE)
14
14
  [![npm package](https://img.shields.io/npm/v/%40michengai%2Fdsh-codex-ui.svg?label=npm%20package)](https://www.npmjs.com/package/@michengai/dsh-codex-ui)
15
+ [![npm 下载量](https://img.shields.io/npm/dt/%40michengai%2Fdsh-codex-ui.svg?label=npm%20%E4%B8%8B%E8%BD%BD%E9%87%8F&v=2)](https://www.npmjs.com/package/@michengai/dsh-codex-ui)
15
16
  [![DSH Web Plugin](https://img.shields.io/badge/DSH%20Web-Plugin-0f766e.svg)](https://github.com/MichengAI/dsh-codex-ui)
16
17
  [![Node.js 22 or later](https://img.shields.io/badge/Node.js-22%20or%20later-339933.svg?logo=node.js&logoColor=white)](https://nodejs.org/)
17
18
 
package/dist/client.js CHANGED
@@ -4061,18 +4061,6 @@ header [data-dcu-title-folder] svg,header [data-dcu-title-more] svg{display:bloc
4061
4061
  "workspace.actions": "{name} 的项目操作",
4062
4062
  "workspace.taskCount": "{count} 个任务",
4063
4063
  "workspace.edit": "编辑项目",
4064
- "permission.read-only.title": "请求批准",
4065
- "permission.read-only.description": "编辑外部文件和使用互联网时始终询问",
4066
- "permission.read-only.trigger": "请求批准",
4067
- "permission.workspace-write.title": "帮我批准",
4068
- "permission.workspace-write.description": "仅对检测到的风险操作请求批准",
4069
- "permission.workspace-write.trigger": "帮我批准",
4070
- "permission.danger-full-access.title": "完全访问权限",
4071
- "permission.danger-full-access.description": "可不受限制地访问互联网和您电脑上的任何文件",
4072
- "permission.danger-full-access.trigger": "完全访问",
4073
- "permission.custom.title": "自定义",
4074
- "permission.custom.description": "使用当前会话的自定义权限预设",
4075
- "permission.custom.trigger": "自定义",
4076
4064
  "sessions.close": "关闭",
4077
4065
  "sessions.cancel": "取消",
4078
4066
  "sessions.save": "保存",
@@ -4184,18 +4172,6 @@ header [data-dcu-title-folder] svg,header [data-dcu-title-more] svg{display:bloc
4184
4172
  "workspace.actions": "Project actions for {name}",
4185
4173
  "workspace.taskCount": "{count} tasks",
4186
4174
  "workspace.edit": "Edit project",
4187
- "permission.read-only.title": "Request approval",
4188
- "permission.read-only.description": "Always ask when editing external files or using the internet",
4189
- "permission.read-only.trigger": "Request approval",
4190
- "permission.workspace-write.title": "Help me approve",
4191
- "permission.workspace-write.description": "Only ask for detected risky operations",
4192
- "permission.workspace-write.trigger": "Help me approve",
4193
- "permission.danger-full-access.title": "Full access",
4194
- "permission.danger-full-access.description": "Unrestricted access to the internet and any files on your computer",
4195
- "permission.danger-full-access.trigger": "Full access",
4196
- "permission.custom.title": "Custom",
4197
- "permission.custom.description": "Use the current session custom permission preset",
4198
- "permission.custom.trigger": "Custom",
4199
4175
  "sessions.close": "Close",
4200
4176
  "sessions.cancel": "Cancel",
4201
4177
  "sessions.save": "Save",
@@ -4262,154 +4238,6 @@ header [data-dcu-title-folder] svg,header [data-dcu-title-more] svg{display:bloc
4262
4238
  "turns.untitled": "Untitled prompt",
4263
4239
  "turns.jump": "Jump to turn {index}: {summary}"
4264
4240
  };
4265
- //#endregion
4266
- //#region src/client/permission-i18n.ts
4267
- const PERMISSION_I18N_STYLE = "[data-dcu-perm-title]{display:block;font-size:14px;line-height:20px;font-weight:500}[data-dcu-perm-desc]{display:block;margin-top:2px;color:var(--dcu-sidebar-secondary,#9ca39f);font-size:12px;line-height:18px;font-weight:400}button[role=menuitem][data-dcu-perm]{align-items:flex-start;height:auto;min-height:44px;padding-top:8px;padding-bottom:8px}button[data-dcu-perm=\"danger-full-access\"],button[data-dcu-perm=\"danger-full-access\"] svg,button[data-dcu-perm=\"danger-full-access\"] [data-dcu-perm-title],button[data-dcu-perm=\"danger-full-access\"] [data-dcu-perm-desc]{color:var(--dsw-alias-state-warn-label,#e3942a)}";
4268
- const ENGLISH_ALIASES = [
4269
- ["Workspace Write", "workspace-write"],
4270
- ["workspace-write", "workspace-write"],
4271
- ["Read Only", "read-only"],
4272
- ["read-only", "read-only"],
4273
- ["Full access", "danger-full-access"],
4274
- ["Full Access", "danger-full-access"],
4275
- ["danger-full-access", "danger-full-access"],
4276
- ["Custom", "custom"],
4277
- ["custom", "custom"]
4278
- ];
4279
- const LOCAL_ALIASES = [
4280
- ["帮我批准", "workspace-write"],
4281
- ["Help me approve", "workspace-write"],
4282
- ["请求批准", "read-only"],
4283
- ["Request approval", "read-only"],
4284
- ["完全访问权限", "danger-full-access"],
4285
- ["完全访问", "danger-full-access"],
4286
- ["自定义", "custom"]
4287
- ];
4288
- /** 把宿主刚写上的英文权限名解析成本插件标识;英文优先于旧中文。 */
4289
- function permissionIdFromLabel(text) {
4290
- const normalized = text.trim().replace(/\s+/g, " ");
4291
- for (const [alias, id] of ENGLISH_ALIASES) if (normalized === alias || normalized.includes(alias)) return id;
4292
- for (const [alias, id] of LOCAL_ALIASES) if (normalized === alias || normalized.includes(alias)) return id;
4293
- }
4294
- /** 把夹在中文确认框里的 Full access 换成当前语言名称。 */
4295
- function replaceFullAccessLabel(text, localized) {
4296
- if (localized === "Full access") return text;
4297
- return text.replaceAll("Full access", ` ${localized} `).replaceAll("Full Access", ` ${localized} `).replace(/ {2,}/g, " ").replace(/ ([??。,,!!])/g, "$1").trim();
4298
- }
4299
- function replaceEmbeddedFullAccess(root, localized) {
4300
- if (typeof document === "undefined" || localized === "Full access") return 0;
4301
- const doc = root instanceof Document ? root : root.ownerDocument;
4302
- if (doc === null) return 0;
4303
- const walker = doc.createTreeWalker(root, NodeFilter.SHOW_TEXT);
4304
- let changed = 0;
4305
- let node = walker.nextNode();
4306
- while (node !== null) {
4307
- const value = node.nodeValue;
4308
- if (value !== null && (value.includes("Full access") || value.includes("Full Access"))) {
4309
- node.nodeValue = replaceFullAccessLabel(value, localized);
4310
- changed += 1;
4311
- }
4312
- node = walker.nextNode();
4313
- }
4314
- return changed;
4315
- }
4316
- function permissionCopy(id, t) {
4317
- return {
4318
- title: t(`permission.${id}.title`),
4319
- description: t(`permission.${id}.description`),
4320
- trigger: t(`permission.${id}.trigger`)
4321
- };
4322
- }
4323
- function leafTextSpans(root) {
4324
- return [...root.querySelectorAll("span")].filter((span) => span.childElementCount === 0 && (span.textContent ?? "").trim() !== "");
4325
- }
4326
- function visibleText(root) {
4327
- return (root.textContent ?? "").replace(/\s+/g, " ").trim();
4328
- }
4329
- function applyCopy(label, copy, asTrigger) {
4330
- const title = asTrigger ? copy.trigger : copy.title;
4331
- let titleNode = label.querySelector("[data-dcu-perm-title]");
4332
- let descNode = label.querySelector("[data-dcu-perm-desc]");
4333
- if (titleNode === null) {
4334
- label.textContent = "";
4335
- titleNode = label.ownerDocument.createElement("span");
4336
- titleNode.setAttribute("data-dcu-perm-title", "1");
4337
- label.append(titleNode);
4338
- }
4339
- if (titleNode.textContent !== title) titleNode.textContent = title;
4340
- if (asTrigger) {
4341
- descNode?.remove();
4342
- return;
4343
- }
4344
- if (descNode === null) {
4345
- descNode = label.ownerDocument.createElement("span");
4346
- descNode.setAttribute("data-dcu-perm-desc", "1");
4347
- label.append(descNode);
4348
- }
4349
- if (descNode.textContent !== copy.description) descNode.textContent = copy.description;
4350
- }
4351
- /** 把当前文档里的权限选择器改成当前语言的 Codex 文案。 */
4352
- function localizePermissionMenus(root, t) {
4353
- let changed = 0;
4354
- for (const button of root.querySelectorAll("button")) {
4355
- const menuitem = button.getAttribute("role") === "menuitem";
4356
- const marked = button.getAttribute("data-dcu-perm");
4357
- const spans = leafTextSpans(button);
4358
- const id = permissionIdFromLabel(visibleText(button)) ?? marked ?? void 0;
4359
- if (id === void 0) continue;
4360
- const label = button.querySelector("[data-dcu-perm-title]")?.parentElement ?? spans[0];
4361
- if (label === void 0) continue;
4362
- const copy = permissionCopy(id, t);
4363
- const nextTitle = menuitem ? copy.title : copy.trigger;
4364
- const titleNode = label.querySelector("[data-dcu-perm-title]");
4365
- const descNode = label.querySelector("[data-dcu-perm-desc]");
4366
- if (marked === id && titleNode?.textContent === nextTitle && (menuitem ? descNode?.textContent === copy.description : descNode === null)) continue;
4367
- button.setAttribute("data-dcu-perm", id);
4368
- applyCopy(label, copy, !menuitem);
4369
- changed += 1;
4370
- }
4371
- changed += replaceEmbeddedFullAccess(root, t("permission.danger-full-access.trigger"));
4372
- return changed;
4373
- }
4374
- function observePermissionMenus(t) {
4375
- if (typeof document === "undefined") return () => {};
4376
- const styleId = "dcu-permission-i18n";
4377
- if (document.getElementById(styleId) === null) {
4378
- const style = document.createElement("style");
4379
- style.id = styleId;
4380
- style.textContent = PERMISSION_I18N_STYLE;
4381
- document.head.append(style);
4382
- }
4383
- let applying = false;
4384
- let frame;
4385
- const apply = () => {
4386
- if (applying) return;
4387
- applying = true;
4388
- try {
4389
- localizePermissionMenus(document, t);
4390
- } finally {
4391
- applying = false;
4392
- }
4393
- };
4394
- const schedule = () => {
4395
- if (frame !== void 0) return;
4396
- frame = window.requestAnimationFrame(() => {
4397
- frame = void 0;
4398
- apply();
4399
- });
4400
- };
4401
- apply();
4402
- const observer = new MutationObserver(schedule);
4403
- observer.observe(document.body, {
4404
- childList: true,
4405
- subtree: true,
4406
- characterData: true
4407
- });
4408
- return () => {
4409
- observer.disconnect();
4410
- if (frame !== void 0) window.cancelAnimationFrame(frame);
4411
- };
4412
- }
4413
4241
  const SETTINGS_NAV_ICON_HTML = {
4414
4242
  experts: "<path fill=\"currentColor\" d=\"M11.0307 5.46369C11.0305 3.78995 9.6734 2.43357 7.99961 2.43357C6.32601 2.43379 4.96972 3.79009 4.96949 5.46369C4.96949 7.13748 6.32587 8.49455 7.99961 8.49477C9.67354 8.49477 11.0307 7.13762 11.0307 5.46369ZM12.3163 5.46369C12.3163 7.84777 10.3837 9.78042 7.99961 9.78042C5.61572 9.7802 3.68288 7.84763 3.68288 5.46369C3.6831 3.07993 5.61586 1.14718 7.99961 1.14695C10.3836 1.14695 12.3161 3.0798 12.3163 5.46369Z\"/><path fill=\"currentColor\" d=\"M8.00002 10.3316C11.7343 10.3316 14.1864 11.8997 15.0387 14.4445L14.4292 14.6483L13.8197 14.8531C13.1955 12.9893 11.3673 11.6182 8.00002 11.6182C4.63277 11.6182 2.80455 12.9893 2.18031 14.8531L1.5708 14.6483L0.961304 14.4445C1.81368 11.8997 4.26579 10.3316 8.00002 10.3316Z\"/>",
4415
4243
  skills: "<path fill=\"currentColor\" d=\"M12.5113 15.4067C12.4395 15.6249 12.1308 15.6249 12.059 15.4067L11.643 14.1416C11.454 13.567 11.0033 13.1164 10.4288 12.9274L9.16369 12.5113C8.94544 12.4395 8.94544 12.1308 9.16369 12.059L10.4288 11.643C11.0033 11.454 11.454 11.0033 11.643 10.4288L12.059 9.16369C12.1308 8.94544 12.4395 8.94544 12.5113 9.16369L12.9274 10.4288C13.1164 11.0033 13.567 11.454 14.1416 11.643L15.4067 12.059C15.6249 12.1308 15.6249 12.4395 15.4067 12.5113L14.1416 12.9274C13.567 13.1164 13.1164 13.567 12.9274 14.1416L12.5113 15.4067Z\"/><path fill=\"currentColor\" d=\"M9.02246 0.546878C9.9822 0.546878 10.7564 0.545403 11.374 0.612307C12.0042 0.680586 12.5515 0.826244 13.0273 1.17188C13.3052 1.37376 13.5501 1.61868 13.752 1.89649C14.0975 2.37225 14.2432 2.91984 14.3115 3.54981C14.3784 4.16727 14.377 4.94206 14.377 5.90137V8.51367C13.9611 8.29533 13.5071 8.13985 13.0273 8.06055V5.90137C13.0273 4.9121 13.0259 4.22322 12.9688 3.69532C12.9129 3.18044 12.8098 2.89782 12.6592 2.69043C12.5406 2.52724 12.3966 2.38326 12.2334 2.26465C12.026 2.11404 11.7437 2.0109 11.2285 1.95508C10.7005 1.89789 10.0122 1.89649 9.02246 1.89649H6.55371C5.56395 1.89649 4.87569 1.89787 4.34766 1.95508C3.83242 2.01092 3.55022 2.11398 3.34278 2.26465C3.17953 2.38329 3.03564 2.52719 2.91699 2.69043C2.76642 2.89782 2.66325 3.18042 2.60742 3.69532C2.55027 4.22322 2.54883 4.9121 2.54883 5.90137V10.0986C2.54883 11.0878 2.55031 11.7768 2.60742 12.3047C2.66326 12.8196 2.76642 13.1032 2.91699 13.3105C3.03558 13.4736 3.17966 13.6178 3.34278 13.7363C3.5502 13.8869 3.83265 13.9901 4.34766 14.0459C4.87568 14.1031 5.56398 14.1035 6.55371 14.1035H8.08399C8.27443 14.6025 8.55077 15.0585 8.89551 15.4541H6.55371C5.59402 15.4541 4.81976 15.4546 4.20215 15.3877C3.57204 15.3194 3.02468 15.1738 2.54883 14.8281C2.27111 14.6263 2.02606 14.3813 1.82422 14.1035C1.47883 13.6278 1.33293 13.08 1.26465 12.4502C1.19783 11.8327 1.19922 11.0579 1.19922 10.0986V5.90137C1.19922 4.94206 1.1978 4.16727 1.26465 3.54981C1.33295 2.91984 1.47867 2.37225 1.82422 1.89649C2.02613 1.61864 2.27098 1.37379 2.54883 1.17188C3.02472 0.826181 3.57197 0.6806 4.20215 0.612307C4.81976 0.545393 5.594 0.546877 6.55371 0.546878H9.02246ZM9.19629 9.14649H4.5459V7.84571H9.19629V9.14649ZM11.0303 6.10645H4.5459V4.80567H11.0303V6.10645Z\"/>",
@@ -4796,7 +4624,6 @@ header [data-dcu-title-folder] svg,header [data-dcu-title-more] svg{display:bloc
4796
4624
  en
4797
4625
  }), "michengai-codex-ui: dictionaries");
4798
4626
  const t = ctx.locale.bind(NS);
4799
- ctx.effect(() => observePermissionMenus((key) => t(key)), "michengai-codex-ui: permission i18n");
4800
4627
  ctx.effect(() => observeSlimSidebar(), "michengai-codex-ui: slim sidebar");
4801
4628
  ctx.effect(() => observeSettingsNavIcons(), "michengai-codex-ui: settings nav icons");
4802
4629
  ctx.effect(() => observeConversationHeader(), "michengai-codex-ui: conversation header");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@michengai/dsh-codex-ui",
3
- "version": "0.2.68",
3
+ "version": "0.2.70",
4
4
  "description": "以 Codex 风格重构 DSH Web 侧栏的独立客户端插件",
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": {
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "scripts": {
55
55
  "build": "tsc --noEmit && tsdown",
56
- "test": "tsx tests/permission-i18n.assert.ts && tsx tests/hover-tip.assert.ts && tsx tests/companion-slots.assert.ts && tsx tests/channel-api.assert.ts && tsx tests/schedule-sessions.assert.ts && tsx tests/session-tree.assert.ts && tsx tests/pinned-sessions.assert.ts && tsx tests/session-manager.assert.ts && tsx tests/workspace-browser.assert.ts && tsx tests/sidebar-search.assert.ts && tsx tests/settings-navigation.assert.ts && tsx tests/settings-nav-icons.assert.ts && tsx tests/locales.assert.ts && vitest run tests/client-runtime.integration.spec.ts && tsx tests/settings-integration.assert.ts && tsx tests/about-dependencies.assert.ts && tsx tests/dependency-manager.assert.ts && tsx tests/conversation-bubbles.assert.ts && tsx tests/conversation-header.assert.ts && tsx tests/conversation-visuals.assert.ts && tsdown && tsx tests/client-bundle.assert.ts && tsx tests/codex-suite.assert.ts"
56
+ "test": "tsx tests/hover-tip.assert.ts && tsx tests/companion-slots.assert.ts && tsx tests/channel-api.assert.ts && tsx tests/schedule-sessions.assert.ts && tsx tests/session-tree.assert.ts && tsx tests/pinned-sessions.assert.ts && tsx tests/session-manager.assert.ts && tsx tests/workspace-browser.assert.ts && tsx tests/sidebar-search.assert.ts && tsx tests/settings-navigation.assert.ts && tsx tests/settings-nav-icons.assert.ts && tsx tests/locales.assert.ts && vitest run tests/client-runtime.integration.spec.ts && tsx tests/settings-integration.assert.ts && tsx tests/about-dependencies.assert.ts && tsx tests/dependency-manager.assert.ts && tsx tests/conversation-bubbles.assert.ts && tsx tests/conversation-header.assert.ts && tsx tests/conversation-visuals.assert.ts && tsdown && tsx tests/client-bundle.assert.ts && tsx tests/codex-suite.assert.ts"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "@deepseek-ai/cordis": ">=4.0.1 <5.0.0",