@michengai/dsh-codex-ui 2.4.1 → 2.4.3
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/CHANGELOG.md +18 -0
- package/CHANGELOG.zh-CN.md +18 -0
- package/lib/client.js +108 -24
- package/lib/composer-plugin.d.mts +1 -1
- package/lib/composer-plugin.mjs +53 -36
- package/lib/index.d.mts +12 -1
- package/lib/index.mjs +43 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.4.3] - 2026-11-22
|
|
4
|
+
|
|
5
|
+
- **Improve Prediction Ghost Text Visibility and Layering (Issue #110)**:
|
|
6
|
+
- Fixed an issue where prediction suggestions could be obscured by card backgrounds or input containers, ensuring ghost completions remain clearly legible.
|
|
7
|
+
- **Fix Network Requests and Error Logs When Composer Feature is Disabled (Issue #112)**:
|
|
8
|
+
- Fixed an issue where disabling input composer enhancements in settings caused background probes to repeatedly log 404 errors;
|
|
9
|
+
- Probes now cleanly detect disabled state and halt unnecessary polling, keeping developer tools and network traffic clean.
|
|
10
|
+
- **Enhance Coexistence Compatibility with Third-Party Plugins on Hero Page (Issue #111)**:
|
|
11
|
+
- Fixed an issue where running alongside third-party workspace enhancement plugins could trigger conflicts and prevent hero components from rendering;
|
|
12
|
+
- Improved interface extension tolerance so workspace selection and search remain smooth and stable when multiple plugins are active.
|
|
13
|
+
|
|
14
|
+
## [2.4.2] - 2026-11-21
|
|
15
|
+
|
|
16
|
+
- **Fix Prediction Candidates Display and Control Text Filtering with Reasoning Models (Issue #108, PR #109)**:
|
|
17
|
+
- Increased default prediction token budget to provide ample reasoning headroom, resolving the issue where ghost suggestions never appeared with certain reasoning models;
|
|
18
|
+
- Improved prediction truncation and candidate recovery to retain usable whole candidates when length limits are reached, preventing single-line completions from being accidentally cleared;
|
|
19
|
+
- Enhanced streaming preview by filtering out prompt echoes and control text, immediately halting when no prediction is available to keep ghost suggestions crisp and accurate.
|
|
20
|
+
|
|
3
21
|
## [2.4.1] - 2026-11-20
|
|
4
22
|
|
|
5
23
|
- **Fix Network Noise and Continuous Error Logs When Theme Feature is Disabled (Issue #107)**:
|
package/CHANGELOG.zh-CN.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## [2.4.3] - 2026-11-22
|
|
4
|
+
|
|
5
|
+
- **提升输入预测幽灵建议文本的层级显示效果(Issue #110)**:
|
|
6
|
+
- 修复了在部分界面卡片或复杂背景下输入预测幽灵建议文本被底层遮挡的问题,保证智能补全提示始终清晰完整可见。
|
|
7
|
+
- **修复输入框增强功能停用时的网络异常与日志报错(Issue #112)**:
|
|
8
|
+
- 修复了在设置中停用输入框增强后,系统仍会在后台探测并持续产生 404 错误的问题;
|
|
9
|
+
- 优化探活行为,停用状态下直接返回关闭状态并停止不必要的后台请求,保持控制台与网络记录干净无杂音。
|
|
10
|
+
- **增强欢迎页项目选择器与第三方插件的共存兼容性(Issue #111)**:
|
|
11
|
+
- 修复了同时启用包含工作区增强的第三方插件(如部分侧栏与文件夹分类插件)时,欢迎页项目选择器可能发生冲突导致界面加载异常的问题;
|
|
12
|
+
- 提升了界面扩展槽位的容错与兼容能力,确保多插件共存时欢迎页各项操作与搜索功能稳定流畅运行。
|
|
13
|
+
|
|
14
|
+
## [2.4.2] - 2026-11-21
|
|
15
|
+
|
|
16
|
+
- **修复输入预测在推理模型下的候选生成与显示异常(Issue #108、PR #109)**:
|
|
17
|
+
- 调高输入预测的默认生成 token 预算,为推理模型预留充分的思考空间,彻底解决在部分思考模型下幽灵候选文本持续为空的问题;
|
|
18
|
+
- 优化预测候选截断与回收机制,在输出达到长度限制时保留已生成可用的完整候选,避免单行文本被意外清空;
|
|
19
|
+
- 改进流式打字预览体验,自动过滤模型复述的提示词与控制标记,遇到无需建议时即刻停止,保持幽灵文本干净准确。
|
|
20
|
+
|
|
3
21
|
## [2.4.1] - 2026-11-20
|
|
4
22
|
|
|
5
23
|
- **修复主题子插件停用时的网络异常与持续报错(Issue #107)**:
|
package/lib/client.js
CHANGED
|
@@ -9940,6 +9940,34 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
9940
9940
|
};
|
|
9941
9941
|
}
|
|
9942
9942
|
//#endregion
|
|
9943
|
+
//#region src/client/composer/slot-safety.ts
|
|
9944
|
+
/**
|
|
9945
|
+
* 安全注册 single slot:
|
|
9946
|
+
* 1. 当遇到同 priority 碰撞报错(例如被第三方插件占用)时,自动递减 priority 至更低档位重试:
|
|
9947
|
+
* 既规避同 priority 冲突崩溃,又在 DSH single slot 机制中以更低数值优先胜出渲染(lowest renders);
|
|
9948
|
+
* 2. 超过最大重试次数或发生不可恢复异常时安全降级,打印警告并返回 no-op 清理函数,
|
|
9949
|
+
* 确保绝不抛出未捕获异常阻塞插件后续生命周期的加载。
|
|
9950
|
+
*/
|
|
9951
|
+
function registerSingleSlotSafely(slots, options, component, maxRetries = 5) {
|
|
9952
|
+
let priority = options.priority ?? 0;
|
|
9953
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) try {
|
|
9954
|
+
return slots.register({
|
|
9955
|
+
...options,
|
|
9956
|
+
priority
|
|
9957
|
+
}, component);
|
|
9958
|
+
} catch (err) {
|
|
9959
|
+
if ((err instanceof Error ? err.message : String(err)).includes("already has a registration at priority") && attempt < maxRetries) {
|
|
9960
|
+
const nextPriority = priority - 1;
|
|
9961
|
+
console.info(`[codex-ui] single slot "${options.name}" already occupied at priority ${priority}, fallback to priority ${nextPriority} to win registration`);
|
|
9962
|
+
priority = nextPriority;
|
|
9963
|
+
continue;
|
|
9964
|
+
}
|
|
9965
|
+
console.warn(`[codex-ui] Failed to register single slot "${options.name}":`, err);
|
|
9966
|
+
return () => {};
|
|
9967
|
+
}
|
|
9968
|
+
return () => {};
|
|
9969
|
+
}
|
|
9970
|
+
//#endregion
|
|
9943
9971
|
//#region src/client/composer/input-history.ts
|
|
9944
9972
|
const HISTORY_KEY = "michengai.codex-ui.input-history.v1";
|
|
9945
9973
|
const LEGACY_HISTORY_KEY = "michengai.btw.history.v1";
|
|
@@ -11001,6 +11029,32 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
11001
11029
|
});
|
|
11002
11030
|
}
|
|
11003
11031
|
//#endregion
|
|
11032
|
+
//#region src/composer-prediction-format.ts
|
|
11033
|
+
const PREDICTION_CUES = {
|
|
11034
|
+
next: "Predict the user's next message.",
|
|
11035
|
+
continue: "Write only the continuation text."
|
|
11036
|
+
};
|
|
11037
|
+
const PREDICTION_LABELS = {
|
|
11038
|
+
conversation: "Conversation tail (oldest first):",
|
|
11039
|
+
tools: "Recent tool activity (oldest first):",
|
|
11040
|
+
draft: "Draft text ending at the caret:"
|
|
11041
|
+
};
|
|
11042
|
+
const NO_PREDICTION = "NONE";
|
|
11043
|
+
function isNoPrediction(text) {
|
|
11044
|
+
return text.trim().toUpperCase() === NO_PREDICTION;
|
|
11045
|
+
}
|
|
11046
|
+
function predictionLineIdentity(text) {
|
|
11047
|
+
return text.replace(/[.:!?]+$/u, "").trim().toLocaleLowerCase();
|
|
11048
|
+
}
|
|
11049
|
+
const LABEL_IDENTITIES = Object.values(PREDICTION_LABELS).map(predictionLineIdentity);
|
|
11050
|
+
const NO_PREDICTION_IDENTITY = predictionLineIdentity(NO_PREDICTION);
|
|
11051
|
+
/** 只对未结束的末行暂缓显示可能还在输出中的控制文本。 */
|
|
11052
|
+
function isPredictionPromptEcho(identity, cueIdentity, partial = false) {
|
|
11053
|
+
if (identity === "") return true;
|
|
11054
|
+
const matches = (marker) => identity === marker || identity.startsWith(marker) && /[ .:!?]/u.test(identity.charAt(marker.length)) || partial && marker.startsWith(identity);
|
|
11055
|
+
return cueIdentity !== "" && matches(cueIdentity) || LABEL_IDENTITIES.some(matches) || partial && NO_PREDICTION_IDENTITY.startsWith(identity);
|
|
11056
|
+
}
|
|
11057
|
+
//#endregion
|
|
11004
11058
|
//#region src/client/composer/ComposerPredictionOverlay.tsx
|
|
11005
11059
|
/**
|
|
11006
11060
|
* Browser half of composer predictions (1:1 完整无损移植自 dsh-composer-predictions 1.2.8 原版源码)
|
|
@@ -11045,7 +11099,7 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
11045
11099
|
whiteSpace: "nowrap",
|
|
11046
11100
|
pointerEvents: "none",
|
|
11047
11101
|
userSelect: "none",
|
|
11048
|
-
zIndex:
|
|
11102
|
+
zIndex: 8
|
|
11049
11103
|
};
|
|
11050
11104
|
/** The continuation ghost hugs its text and sits where the caret is. */
|
|
11051
11105
|
const CONTINUE_GHOST_STYLE = {
|
|
@@ -11053,7 +11107,7 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
11053
11107
|
gap: "6px",
|
|
11054
11108
|
padding: "0 4px",
|
|
11055
11109
|
borderRadius: "4px",
|
|
11056
|
-
zIndex:
|
|
11110
|
+
zIndex: 9
|
|
11057
11111
|
};
|
|
11058
11112
|
const TEXT_STYLE = {
|
|
11059
11113
|
flex: "1 1 auto",
|
|
@@ -11173,21 +11227,22 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
11173
11227
|
function isTriggerToken(draft) {
|
|
11174
11228
|
return /(?:^|\s)\/[^\s]*$/u.test(draft) || /(?:^|\s)@"?[^\s]*$/u.test(draft);
|
|
11175
11229
|
}
|
|
11176
|
-
/**
|
|
11177
|
-
function streamingCandidate(stream) {
|
|
11230
|
+
/** 流式预览只显示候选,不显示模型复述的提示词。 */
|
|
11231
|
+
function streamingCandidate(stream, mode) {
|
|
11178
11232
|
if (stream.trim().length < STREAM_MIN_CHARS) return "";
|
|
11179
|
-
|
|
11180
|
-
|
|
11181
|
-
|
|
11182
|
-
|
|
11183
|
-
line = cleanLine(line);
|
|
11233
|
+
const lines = stream.split("\n");
|
|
11234
|
+
const cue = predictionLineIdentity(PREDICTION_CUES[mode]);
|
|
11235
|
+
for (const [index, raw] of lines.entries()) {
|
|
11236
|
+
const line = cleanLine(raw);
|
|
11184
11237
|
if (line === "") continue;
|
|
11238
|
+
if (isNoPrediction(line)) return "";
|
|
11239
|
+
if (isPredictionPromptEcho(predictionLineIdentity(line), cue, index === lines.length - 1)) continue;
|
|
11185
11240
|
return line.length > 240 ? line.slice(0, 240) : line;
|
|
11186
11241
|
}
|
|
11187
11242
|
return "";
|
|
11188
11243
|
}
|
|
11189
11244
|
function cleanLine(line) {
|
|
11190
|
-
return line.replace(/^(?:[-*•]|\d+[.)])\s+/u, "").replace(/^["'`\u201c\u201d]+|["'`\u201c\u201d]+$/gu, "").replace(/\s+/gu, " ").trim();
|
|
11245
|
+
return line.trimStart().replace(/^(?:[-*•]|\d+[.)])\s+/u, "").replace(/^user\s*:\s*/iu, "").replace(/^["'`\u201c\u201d]+|["'`\u201c\u201d]+$/gu, "").replace(/\s+/gu, " ").trim();
|
|
11191
11246
|
}
|
|
11192
11247
|
/**
|
|
11193
11248
|
* Join a continuation onto the draft without gluing words together.
|
|
@@ -11455,7 +11510,7 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
11455
11510
|
request,
|
|
11456
11511
|
allowNext
|
|
11457
11512
|
]);
|
|
11458
|
-
const rawCandidate = ghost.items.length > 0 ? ghost.items[Math.min(ghost.index, ghost.items.length - 1)] ?? "" : streamingCandidate(ghost.stream);
|
|
11513
|
+
const rawCandidate = ghost.items.length > 0 ? ghost.items[Math.min(ghost.index, ghost.items.length - 1)] ?? "" : streamingCandidate(ghost.stream, ghost.mode === "continue" ? "continue" : "next");
|
|
11459
11514
|
const current = ghost.mode === "continue" ? joinContinuation(draft, rawCandidate) : rawCandidate;
|
|
11460
11515
|
currentRef.current = current;
|
|
11461
11516
|
const hasCandidate = current !== "";
|
|
@@ -11768,6 +11823,9 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
11768
11823
|
/**
|
|
11769
11824
|
* 读取 Host 状态:子插件是否启用,以及站点级是否允许预测。
|
|
11770
11825
|
* 网络/解析失败一律返回“全部关闭”,避免在宿主不可达时仍然悄悄花 token。
|
|
11826
|
+
*
|
|
11827
|
+
* `explicitlyDisabled` 区分两种关闭:宿主明确回答 `{ enabled: false }`(子插件被停用)
|
|
11828
|
+
* 与端点不存在/不可达(404、网关未就绪)。前者不再重试,后者允许冷启有界退避。
|
|
11771
11829
|
*/
|
|
11772
11830
|
async function fetchComposerStatus() {
|
|
11773
11831
|
try {
|
|
@@ -11777,17 +11835,20 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
11777
11835
|
});
|
|
11778
11836
|
if (!response.ok) return {
|
|
11779
11837
|
enabled: false,
|
|
11780
|
-
prediction: false
|
|
11838
|
+
prediction: false,
|
|
11839
|
+
explicitlyDisabled: false
|
|
11781
11840
|
};
|
|
11782
11841
|
const data = await response.json();
|
|
11783
11842
|
return {
|
|
11784
11843
|
enabled: data?.enabled === true,
|
|
11785
|
-
prediction: data?.prediction !== false
|
|
11844
|
+
prediction: data?.prediction !== false,
|
|
11845
|
+
explicitlyDisabled: data?.enabled === false
|
|
11786
11846
|
};
|
|
11787
11847
|
} catch {
|
|
11788
11848
|
return {
|
|
11789
11849
|
enabled: false,
|
|
11790
|
-
prediction: false
|
|
11850
|
+
prediction: false,
|
|
11851
|
+
explicitlyDisabled: false
|
|
11791
11852
|
};
|
|
11792
11853
|
}
|
|
11793
11854
|
}
|
|
@@ -11870,7 +11931,7 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
11870
11931
|
...pickerInjected
|
|
11871
11932
|
});
|
|
11872
11933
|
}
|
|
11873
|
-
const unregisterWorkspacePicker = ctx.slots.inject("conversation.hero.workspace", () => ctx.slots
|
|
11934
|
+
const unregisterWorkspacePicker = ctx.slots.inject("conversation.hero.workspace", () => registerSingleSlotSafely(ctx.slots, {
|
|
11874
11935
|
name: "conversation.hero.workspace",
|
|
11875
11936
|
priority: -100,
|
|
11876
11937
|
locale: NS
|
|
@@ -11903,21 +11964,47 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
11903
11964
|
if (typeof document !== "undefined") document.querySelectorAll("[data-dcu-width-handle]").forEach((el) => el.remove());
|
|
11904
11965
|
};
|
|
11905
11966
|
};
|
|
11906
|
-
|
|
11967
|
+
let retryTimer;
|
|
11968
|
+
let startupRetryCount = 0;
|
|
11969
|
+
const MAX_STARTUP_RETRIES = 3;
|
|
11970
|
+
const clearRetry = () => {
|
|
11971
|
+
if (retryTimer !== void 0) {
|
|
11972
|
+
clearTimeout(retryTimer);
|
|
11973
|
+
retryTimer = void 0;
|
|
11974
|
+
}
|
|
11975
|
+
};
|
|
11976
|
+
const sync = async (allowStartupRetry = false) => {
|
|
11907
11977
|
if (disposed) return;
|
|
11908
11978
|
const status = await fetchComposerStatus();
|
|
11909
11979
|
if (disposed) return;
|
|
11910
11980
|
setSubPluginEnabled(status.enabled);
|
|
11911
11981
|
setHostPredictionAllowed(status.prediction);
|
|
11912
11982
|
if (status.enabled) {
|
|
11983
|
+
clearRetry();
|
|
11984
|
+
startupRetryCount = 0;
|
|
11913
11985
|
if (!cleanActive) cleanActive = activate();
|
|
11914
|
-
|
|
11915
|
-
|
|
11916
|
-
|
|
11986
|
+
return;
|
|
11987
|
+
}
|
|
11988
|
+
cleanActive?.();
|
|
11989
|
+
cleanActive = void 0;
|
|
11990
|
+
if (status.explicitlyDisabled) {
|
|
11991
|
+
clearRetry();
|
|
11992
|
+
return;
|
|
11993
|
+
}
|
|
11994
|
+
if (allowStartupRetry && startupRetryCount < MAX_STARTUP_RETRIES) {
|
|
11995
|
+
startupRetryCount += 1;
|
|
11996
|
+
const delay = startupRetryCount * 1e3;
|
|
11997
|
+
clearRetry();
|
|
11998
|
+
retryTimer = setTimeout(() => {
|
|
11999
|
+
retryTimer = void 0;
|
|
12000
|
+
if (!disposed) sync(true);
|
|
12001
|
+
}, delay);
|
|
12002
|
+
return;
|
|
11917
12003
|
}
|
|
12004
|
+
clearRetry();
|
|
11918
12005
|
};
|
|
11919
12006
|
cleanActive = activate();
|
|
11920
|
-
sync();
|
|
12007
|
+
sync(true);
|
|
11921
12008
|
const onFocus = () => {
|
|
11922
12009
|
sync();
|
|
11923
12010
|
};
|
|
@@ -11939,14 +12026,11 @@ html[data-dcu-mobile-web] [data-shortcut-modal="settings"][role="dialog"] {
|
|
|
11939
12026
|
subtree: true
|
|
11940
12027
|
});
|
|
11941
12028
|
}
|
|
11942
|
-
const pollTimer = setInterval(() => {
|
|
11943
|
-
if (typeof document !== "undefined" && document.visibilityState === "visible") sync();
|
|
11944
|
-
}, 15e3);
|
|
11945
12029
|
return () => {
|
|
11946
12030
|
disposed = true;
|
|
11947
12031
|
if (typeof window !== "undefined") window.removeEventListener("focus", onFocus);
|
|
11948
12032
|
observer?.disconnect();
|
|
11949
|
-
|
|
12033
|
+
clearRetry();
|
|
11950
12034
|
cleanActive?.();
|
|
11951
12035
|
cleanActive = void 0;
|
|
11952
12036
|
};
|
|
@@ -20,7 +20,7 @@ type ComposerPluginConfig = {
|
|
|
20
20
|
model?: string;
|
|
21
21
|
/** 预测调用的 reasoning effort(off | low | high | max) */
|
|
22
22
|
reasoningEffort?: string;
|
|
23
|
-
/** 预测生成的最大 token 数(16 ~ 4096,默认
|
|
23
|
+
/** 预测生成的最大 token 数(16 ~ 4096,默认 1024) */
|
|
24
24
|
maxOutputTokens?: number;
|
|
25
25
|
/** 单次预测超时时间毫秒数(1000 ~ 120000,默认 20000) */
|
|
26
26
|
timeoutMs?: number;
|
package/lib/composer-plugin.mjs
CHANGED
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
import { r as CODEX_UI_API_ENDPOINTS, t as isSubPluginDisabledOnDisk$1 } from "./profile-resolver-DSHfL3KW.mjs";
|
|
2
|
+
//#region src/composer-prediction-format.ts
|
|
3
|
+
const PREDICTION_CUES = {
|
|
4
|
+
next: "Predict the user's next message.",
|
|
5
|
+
continue: "Write only the continuation text."
|
|
6
|
+
};
|
|
7
|
+
const PREDICTION_LABELS = {
|
|
8
|
+
conversation: "Conversation tail (oldest first):",
|
|
9
|
+
tools: "Recent tool activity (oldest first):",
|
|
10
|
+
draft: "Draft text ending at the caret:"
|
|
11
|
+
};
|
|
12
|
+
const NO_PREDICTION = "NONE";
|
|
13
|
+
function isNoPrediction(text) {
|
|
14
|
+
return text.trim().toUpperCase() === NO_PREDICTION;
|
|
15
|
+
}
|
|
16
|
+
function predictionLineIdentity(text) {
|
|
17
|
+
return text.replace(/[.:!?]+$/u, "").trim().toLocaleLowerCase();
|
|
18
|
+
}
|
|
19
|
+
const LABEL_IDENTITIES = Object.values(PREDICTION_LABELS).map(predictionLineIdentity);
|
|
20
|
+
const NO_PREDICTION_IDENTITY = predictionLineIdentity(NO_PREDICTION);
|
|
21
|
+
/** 只对未结束的末行暂缓显示可能还在输出中的控制文本。 */
|
|
22
|
+
function isPredictionPromptEcho(identity, cueIdentity, partial = false) {
|
|
23
|
+
if (identity === "") return true;
|
|
24
|
+
const matches = (marker) => identity === marker || identity.startsWith(marker) && /[ .:!?]/u.test(identity.charAt(marker.length)) || partial && marker.startsWith(identity);
|
|
25
|
+
return cueIdentity !== "" && matches(cueIdentity) || LABEL_IDENTITIES.some(matches) || partial && NO_PREDICTION_IDENTITY.startsWith(identity);
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
2
28
|
//#region src/composer-prediction.ts
|
|
3
29
|
/** 使用自研专属命名空间端点,杜绝与社区插件全局路径冲突 */
|
|
4
30
|
const ENDPOINT = CODEX_UI_API_ENDPOINTS.composerPrediction;
|
|
@@ -6,7 +32,7 @@ const STREAM_ENDPOINT = CODEX_UI_API_ENDPOINTS.composerPredictionStream;
|
|
|
6
32
|
/** One request carries a session id, a mode, and a bounded draft. */
|
|
7
33
|
const MAX_BODY_BYTES = 65536;
|
|
8
34
|
const DEFAULTS = {
|
|
9
|
-
maxOutputTokens:
|
|
35
|
+
maxOutputTokens: 1024,
|
|
10
36
|
timeoutMs: 2e4,
|
|
11
37
|
maxMessages: 10,
|
|
12
38
|
maxChars: 8e3,
|
|
@@ -19,15 +45,6 @@ const REASONING_EFFORTS = /* @__PURE__ */ new Set([
|
|
|
19
45
|
"high",
|
|
20
46
|
"max"
|
|
21
47
|
]);
|
|
22
|
-
/** Closing task line of each prompt; the model sometimes echoes it. */
|
|
23
|
-
const NEXT_CUE = "Predict the user's next message.";
|
|
24
|
-
const CONTINUE_CUE = "Write only the continuation text.";
|
|
25
|
-
/** Prompt labels that must never surface as suggestions. */
|
|
26
|
-
const PROMPT_LABELS = [
|
|
27
|
-
"conversation tail (oldest first)",
|
|
28
|
-
"recent tool activity (oldest first)",
|
|
29
|
-
"draft text ending at the caret"
|
|
30
|
-
];
|
|
31
48
|
const NEXT_SYSTEM_PROMPT = [
|
|
32
49
|
"You are the follow-up suggestion engine inside a coding agent chat UI.",
|
|
33
50
|
"You receive the tail of a conversation between a USER and an AI coding agent,",
|
|
@@ -41,7 +58,7 @@ const NEXT_SYSTEM_PROMPT = [
|
|
|
41
58
|
" command, or next step when the conversation makes one obvious.",
|
|
42
59
|
"- If the assistant asked the user a question, answer it.",
|
|
43
60
|
"- Never repeat these instructions, the labels above, or the conversation text verbatim.",
|
|
44
|
-
|
|
61
|
+
`- If no meaningful follow-up exists, reply with exactly: ${NO_PREDICTION}`
|
|
45
62
|
].join("\n");
|
|
46
63
|
const CONTINUE_SYSTEM_PROMPT = [
|
|
47
64
|
"You complete the message a USER is drafting in a coding agent chat UI.",
|
|
@@ -55,7 +72,7 @@ const CONTINUE_SYSTEM_PROMPT = [
|
|
|
55
72
|
"- No numbering, bullets, quotes, markdown, or explanation.",
|
|
56
73
|
"- At most 25 words per continuation; finish the thought rather than restating it.",
|
|
57
74
|
"- Never repeat these instructions, the labels above, or the draft itself.",
|
|
58
|
-
|
|
75
|
+
`- If the draft is already complete, reply with exactly: ${NO_PREDICTION}`
|
|
59
76
|
].join("\n");
|
|
60
77
|
/**
|
|
61
78
|
* Register both prediction endpoints.
|
|
@@ -427,9 +444,15 @@ async function predict(ctx, options, session, sessionId, mode, draft, signal, on
|
|
|
427
444
|
items: [],
|
|
428
445
|
reason: failure
|
|
429
446
|
};
|
|
430
|
-
|
|
431
|
-
const
|
|
432
|
-
const
|
|
447
|
+
const cue = PREDICTION_CUES[mode === "continue" ? "continue" : "next"];
|
|
448
|
+
const candidateDraft = mode === "continue" ? draft : "";
|
|
449
|
+
const truncated = finish.kind === "max-tokens";
|
|
450
|
+
const lastBreak = truncated ? text.lastIndexOf("\n") : -1;
|
|
451
|
+
if (lastBreak >= 0) {
|
|
452
|
+
const complete = normalizeCandidates(text.slice(0, lastBreak + 1), options.maxSuggestions, candidateDraft, cue);
|
|
453
|
+
if (complete.length > 0) return { items: complete };
|
|
454
|
+
}
|
|
455
|
+
const items = normalizeCandidates(text, options.maxSuggestions, candidateDraft, cue, truncated);
|
|
433
456
|
return items.length === 0 ? {
|
|
434
457
|
items: [],
|
|
435
458
|
reason: "empty"
|
|
@@ -586,18 +609,18 @@ function buildPrompt(session, options, mode, draft) {
|
|
|
586
609
|
budget -= message.text.length;
|
|
587
610
|
kept.unshift(message);
|
|
588
611
|
}
|
|
589
|
-
const lines = [
|
|
612
|
+
const lines = [PREDICTION_LABELS.conversation, JSON.stringify(kept)];
|
|
590
613
|
const recent = options.maxToolNotes > 0 ? notes.slice(-options.maxToolNotes) : [];
|
|
591
614
|
if (recent.length > 0) {
|
|
592
|
-
lines.push("",
|
|
615
|
+
lines.push("", PREDICTION_LABELS.tools);
|
|
593
616
|
for (const note of recent) {
|
|
594
617
|
const status = note.failed ? "failed" : "ok";
|
|
595
618
|
const result = note.result === "" ? "" : ` result=${JSON.stringify(clip(note.result, 320))}`;
|
|
596
619
|
lines.push(`- ${note.name}(${clip(note.input, 320)}) -> ${status}${result}`);
|
|
597
620
|
}
|
|
598
621
|
}
|
|
599
|
-
if (mode === "continue") lines.push("",
|
|
600
|
-
else lines.push("",
|
|
622
|
+
if (mode === "continue") lines.push("", PREDICTION_LABELS.draft, JSON.stringify(draft), "", PREDICTION_CUES.continue);
|
|
623
|
+
else lines.push("", PREDICTION_CUES.next);
|
|
601
624
|
return lines.join("\n");
|
|
602
625
|
}
|
|
603
626
|
function plainText(blocks) {
|
|
@@ -606,27 +629,31 @@ function plainText(blocks) {
|
|
|
606
629
|
function clip(text, maximum) {
|
|
607
630
|
return text.length > maximum ? `${text.slice(0, maximum)}…` : text;
|
|
608
631
|
}
|
|
609
|
-
/**
|
|
610
|
-
function normalizeCandidates(text, maximum, draft, cue = "") {
|
|
632
|
+
/** 清洗、去重并限制模型返回的候选。 */
|
|
633
|
+
function normalizeCandidates(text, maximum, draft, cue = "", partialLastLine = false) {
|
|
611
634
|
const items = [];
|
|
612
635
|
const seen = /* @__PURE__ */ new Set();
|
|
613
636
|
const prefix = draft === "" ? "" : draft.trimEnd();
|
|
614
637
|
const prefixLower = prefix.toLocaleLowerCase();
|
|
615
|
-
const cueIdentity =
|
|
616
|
-
|
|
638
|
+
const cueIdentity = predictionLineIdentity(cue);
|
|
639
|
+
const lines = text.split("\n");
|
|
640
|
+
for (const [index, raw] of lines.entries()) {
|
|
617
641
|
const hadLeadingSpace = /^\s/u.test(raw);
|
|
618
642
|
const line = raw.replace(/^(?:[-*•]|\d+[.)])\s+/u, "").replace(/^user\s*:\s*/iu, "").trim();
|
|
619
643
|
if (line === "") continue;
|
|
620
644
|
let body = line.replace(/^["'`\u201c\u201d]+|["'`\u201c\u201d]+$/gu, "").replace(/\s+/gu, " ");
|
|
621
|
-
if (
|
|
645
|
+
if (isNoPrediction(body)) break;
|
|
646
|
+
const partial = partialLastLine && index === lines.length - 1;
|
|
647
|
+
const originalIdentity = predictionLineIdentity(body);
|
|
648
|
+
if (isPredictionPromptEcho(originalIdentity, cueIdentity, partial)) continue;
|
|
622
649
|
if (prefixLower !== "" && body.toLocaleLowerCase().startsWith(prefixLower)) body = body.slice(prefix.length).replace(/^\s+/u, " ");
|
|
623
650
|
else if (draft !== "" && hadLeadingSpace && !/^\s/u.test(body)) body = ` ${body}`;
|
|
624
651
|
body = draft === "" ? body.trim() : body.replace(/\s+$/u, "");
|
|
625
652
|
if (body.trim() === "") continue;
|
|
626
653
|
body = boundSuggestion(body);
|
|
627
654
|
if (body === "") continue;
|
|
628
|
-
const identity =
|
|
629
|
-
if (
|
|
655
|
+
const identity = predictionLineIdentity(body);
|
|
656
|
+
if (identity !== originalIdentity && isPredictionPromptEcho(identity, cueIdentity, partial)) continue;
|
|
630
657
|
if (seen.has(identity)) continue;
|
|
631
658
|
seen.add(identity);
|
|
632
659
|
items.push(body);
|
|
@@ -634,16 +661,6 @@ function normalizeCandidates(text, maximum, draft, cue = "") {
|
|
|
634
661
|
}
|
|
635
662
|
return items;
|
|
636
663
|
}
|
|
637
|
-
/** Normalize a line for echo comparison: lowercase, no trailing punctuation. */
|
|
638
|
-
function identityOf(text) {
|
|
639
|
-
return text.replace(/[.:!?]+$/u, "").trim().toLocaleLowerCase();
|
|
640
|
-
}
|
|
641
|
-
/** Drop the prompt's own labels and task line when the model echoes them. */
|
|
642
|
-
function isInstructionEcho(identity, cueIdentity) {
|
|
643
|
-
if (identity === "") return true;
|
|
644
|
-
if (cueIdentity !== "" && (identity === cueIdentity || identity.startsWith(`${cueIdentity} `))) return true;
|
|
645
|
-
return PROMPT_LABELS.some((label) => identity === label || identity.startsWith(`${label} `));
|
|
646
|
-
}
|
|
647
664
|
function boundSuggestion(line) {
|
|
648
665
|
if (line.length <= 240) return line;
|
|
649
666
|
const cut = line.slice(0, 240);
|
package/lib/index.d.mts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import { Context } from "@deepseek-ai/cordis";
|
|
2
2
|
//#region src/index.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* composer 子插件被停用时,由主插件补一个只读状态兜底端点。
|
|
5
|
+
*
|
|
6
|
+
* 客户端以「探活 → 启停输入框增强」驱动 UI:子插件在 cordis.patch.yml 里被停用后,
|
|
7
|
+
* 它自己注册的 `/composer` 端点随之消失,探活只能拿到 404,DevTools 里就会持续报错。
|
|
8
|
+
* 这里在磁盘配置确认停用时接管同一路径,返回 `enabled: false`,客户端据此立即收敛。
|
|
9
|
+
* 子插件启用时不注册,避免与 composer 子插件的同名路由冲突(同一时刻只应有一个注册者)。
|
|
10
|
+
*
|
|
11
|
+
* @returns 路由注销函数;未注册时返回 undefined。
|
|
12
|
+
*/
|
|
13
|
+
declare function registerComposerStatusFallback(ctx: Context): (() => void) | undefined;
|
|
3
14
|
type HostRequest = {
|
|
4
15
|
method?: string;
|
|
5
16
|
url?: string;
|
|
@@ -15,4 +26,4 @@ declare const inject: string[];
|
|
|
15
26
|
/** 提供不泄露地址、命令和凭证的连接器目录。 */
|
|
16
27
|
declare function apply(ctx: Context): void;
|
|
17
28
|
//#endregion
|
|
18
|
-
export { RequestBodyTooLargeError, apply, inject, publicDependencyError, readRequestBody };
|
|
29
|
+
export { RequestBodyTooLargeError, apply, inject, publicDependencyError, readRequestBody, registerComposerStatusFallback };
|
package/lib/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as resolveCurrentProfile, r as CODEX_UI_API_ENDPOINTS } from "./profile-resolver-DSHfL3KW.mjs";
|
|
1
|
+
import { n as resolveCurrentProfile, r as CODEX_UI_API_ENDPOINTS, t as isSubPluginDisabledOnDisk } from "./profile-resolver-DSHfL3KW.mjs";
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import { homedir } from "node:os";
|
|
@@ -659,6 +659,41 @@ function writeSectionsDocument(ctx, document) {
|
|
|
659
659
|
//#endregion
|
|
660
660
|
//#region src/index.ts
|
|
661
661
|
const dependenciesEndpoint = CODEX_UI_API_ENDPOINTS.dependencies;
|
|
662
|
+
/**
|
|
663
|
+
* composer 子插件被停用时,由主插件补一个只读状态兜底端点。
|
|
664
|
+
*
|
|
665
|
+
* 客户端以「探活 → 启停输入框增强」驱动 UI:子插件在 cordis.patch.yml 里被停用后,
|
|
666
|
+
* 它自己注册的 `/composer` 端点随之消失,探活只能拿到 404,DevTools 里就会持续报错。
|
|
667
|
+
* 这里在磁盘配置确认停用时接管同一路径,返回 `enabled: false`,客户端据此立即收敛。
|
|
668
|
+
* 子插件启用时不注册,避免与 composer 子插件的同名路由冲突(同一时刻只应有一个注册者)。
|
|
669
|
+
*
|
|
670
|
+
* @returns 路由注销函数;未注册时返回 undefined。
|
|
671
|
+
*/
|
|
672
|
+
function registerComposerStatusFallback(ctx) {
|
|
673
|
+
if (!isSubPluginDisabledOnDisk("codex-ui-composer", void 0, ctx)) return void 0;
|
|
674
|
+
return hostServices(ctx).webServer.register({
|
|
675
|
+
kind: "exact",
|
|
676
|
+
path: CODEX_UI_API_ENDPOINTS.composer,
|
|
677
|
+
handler: async (request, response) => {
|
|
678
|
+
if (request.method && request.method !== "GET") {
|
|
679
|
+
response.writeHead(405, {
|
|
680
|
+
"content-type": "application/json; charset=utf-8",
|
|
681
|
+
"cache-control": "no-store"
|
|
682
|
+
});
|
|
683
|
+
response.end(JSON.stringify({ error: "Method Not Allowed" }));
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
response.writeHead(200, {
|
|
687
|
+
"content-type": "application/json; charset=utf-8",
|
|
688
|
+
"cache-control": "no-store"
|
|
689
|
+
});
|
|
690
|
+
response.end(JSON.stringify({
|
|
691
|
+
enabled: false,
|
|
692
|
+
prediction: false
|
|
693
|
+
}));
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
}
|
|
662
697
|
function headerValue(headers, name) {
|
|
663
698
|
const value = headers[name];
|
|
664
699
|
if (typeof value === "string") return value;
|
|
@@ -729,6 +764,12 @@ function apply(ctx) {
|
|
|
729
764
|
noteHostInstallState(event);
|
|
730
765
|
});
|
|
731
766
|
}, "codex-ui: host plugin-manager install state");
|
|
767
|
+
ctx.effect(() => {
|
|
768
|
+
const disposeFallback = registerComposerStatusFallback(ctx);
|
|
769
|
+
return () => {
|
|
770
|
+
disposeFallback?.();
|
|
771
|
+
};
|
|
772
|
+
}, "michengai-codex-ui: composer status fallback");
|
|
732
773
|
ctx.effect(() => {
|
|
733
774
|
const disposeDependencies = host.webServer.register({
|
|
734
775
|
kind: "exact",
|
|
@@ -872,4 +913,4 @@ function apply(ctx) {
|
|
|
872
913
|
}, "michengai-codex-ui: catalogs");
|
|
873
914
|
}
|
|
874
915
|
//#endregion
|
|
875
|
-
export { RequestBodyTooLargeError, apply, inject, publicDependencyError, readRequestBody };
|
|
916
|
+
export { RequestBodyTooLargeError, apply, inject, publicDependencyError, readRequestBody, registerComposerStatusFallback };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@michengai/dsh-codex-ui",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.3",
|
|
4
4
|
"description": "DSH Codex UI — 为 DeepSeek Harness 提供极速历史召回、全屏设置皮肤、原生物理毛玻璃换肤、模块化侧栏与桌面原生窗口菜单 · Input enhancement, settings skin, native glass theme, modular sidebar, and desktop titlebar menu for DSH",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"publishConfig": {
|