zcode-pro 0.20.2 → 0.20.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/dist/inject.js +26 -0
- package/package.json +1 -1
- package/src/host/helper.mjs +1 -1
- package/src/inject/features/title-gen.js +41 -0
package/dist/inject.js
CHANGED
|
@@ -5892,6 +5892,20 @@
|
|
|
5892
5892
|
return ((el ? el.textContent : r.innerText) || "").trim();
|
|
5893
5893
|
}).filter(Boolean);
|
|
5894
5894
|
}
|
|
5895
|
+
var URL_RE = /https?:\/\/[^\s\u4e00-\u9fff\u3000-\u303f\uff00-\uffef]+/g;
|
|
5896
|
+
function assistantText() {
|
|
5897
|
+
const els = [...document.querySelectorAll('[class*="@md/conversation"] [class*="assistant-row"]')].filter((e) => !e.querySelector("[data-is-streaming]"));
|
|
5898
|
+
const last = els[els.length - 1];
|
|
5899
|
+
if (!last) return "";
|
|
5900
|
+
const text = (last.innerText || "").replace(URL_RE, "").trim();
|
|
5901
|
+
return text.slice(0, 600);
|
|
5902
|
+
}
|
|
5903
|
+
function linkDominant(t2) {
|
|
5904
|
+
const raw = t2.replace(/\s+/g, "");
|
|
5905
|
+
if (!raw) return true;
|
|
5906
|
+
const stripped = raw.replace(URL_RE, "");
|
|
5907
|
+
return stripped.length < raw.length / 3;
|
|
5908
|
+
}
|
|
5895
5909
|
async function onNewTaskRow(key) {
|
|
5896
5910
|
const selDeadline = Date.now() + SELECT_WAIT_MS;
|
|
5897
5911
|
while (currentKey() !== key && Date.now() < selDeadline) await sleep(200);
|
|
@@ -5946,6 +5960,18 @@
|
|
|
5946
5960
|
convObserver.disconnect();
|
|
5947
5961
|
}
|
|
5948
5962
|
if (!texts.length) return;
|
|
5963
|
+
if (linkDominant(texts.join("\n"))) {
|
|
5964
|
+
const deadline = Date.now() + 6e4;
|
|
5965
|
+
while (Date.now() < deadline) {
|
|
5966
|
+
await sleep(2e3);
|
|
5967
|
+
if (currentKey() !== key) continue;
|
|
5968
|
+
const a = assistantText();
|
|
5969
|
+
if (a && a.length > 80) {
|
|
5970
|
+
texts.push(`\uFF08\u9996\u8F6E\u56DE\u7B54\u6458\u8981\uFF09${a}`);
|
|
5971
|
+
break;
|
|
5972
|
+
}
|
|
5973
|
+
}
|
|
5974
|
+
}
|
|
5949
5975
|
const callTitleGen = () => rpc("/title-gen/run", { method: "POST", body: { sessId, text: texts.join("\n") } }).catch(() => null);
|
|
5950
5976
|
let res = await callTitleGen();
|
|
5951
5977
|
for (const delay of [5e3, 2e4]) {
|
package/package.json
CHANGED
package/src/host/helper.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import { reorderWorkspaceTasks, reorderGroupMembers } from './taskOrder.mjs';
|
|
|
17
17
|
import { webdavRequest, webdavPutWithMkcol, webdavHttpText, parseWebdavListing, findCurl } from './webdav.mjs';
|
|
18
18
|
import { resolveZcodeExecutable } from './paths.mjs';
|
|
19
19
|
|
|
20
|
-
const VERSION = '0.20.
|
|
20
|
+
const VERSION = '0.20.3';
|
|
21
21
|
|
|
22
22
|
// 全局提示词固定在用户主目录:官方加载器按 HOME/USERPROFILE 拼 .zcode/AGENTS.md,
|
|
23
23
|
// 不读 ZCODE_DATA_BASE_DIR(数据根迁走时全局指令仍在原位)。
|
|
@@ -54,6 +54,31 @@ function userTexts() {
|
|
|
54
54
|
.filter(Boolean);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
// 会话区当前的助手回答文本(最后一条,截头去尾):链接占比高的提问场景下,
|
|
58
|
+
// 用户消息里几乎只有 URL,起名模型无从概括;首轮回答必然复述了真实任务。
|
|
59
|
+
// URL 正则与 linkDominant 共用一份(排除 CJK 字符作边界,中文紧随链接不被吞)
|
|
60
|
+
const URL_RE = /https?:\/\/[^\s\u4e00-\u9fff\u3000-\u303f\uff00-\uffef]+/g;
|
|
61
|
+
function assistantText() {
|
|
62
|
+
// 只取非流式中的回答——流式里的半截文本不是完整任务描述;取最后一条
|
|
63
|
+
// 完整的(等待窗口内若已有多轮,最新回答最能概括任务)
|
|
64
|
+
const els = [...document.querySelectorAll('[class*="@md/conversation"] [class*="assistant-row"]')]
|
|
65
|
+
.filter((e) => !e.querySelector('[data-is-streaming]'));
|
|
66
|
+
const last = els[els.length - 1];
|
|
67
|
+
if (!last) return '';
|
|
68
|
+
const text = (last.innerText || '').replace(URL_RE, '').trim();
|
|
69
|
+
return text.slice(0, 600);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// 提问文本是否“链接为主”(去链接后剩余内容不足三分之一)——决定要不要
|
|
73
|
+
// 把助手回答补充进取名素材
|
|
74
|
+
function linkDominant(t) {
|
|
75
|
+
const raw = t.replace(/\s+/g, '');
|
|
76
|
+
if (!raw) return true;
|
|
77
|
+
// URL 结束边界不能只用 \S:中文紧随链接时会被一并吞掉(“链接和说明”被整段删)
|
|
78
|
+
const stripped = raw.replace(URL_RE, '');
|
|
79
|
+
return stripped.length < raw.length / 3;
|
|
80
|
+
}
|
|
81
|
+
|
|
57
82
|
async function onNewTaskRow(key) {
|
|
58
83
|
// 新任务行创建时选中标记可能晚一拍;短暂等待它成为当前会话,
|
|
59
84
|
// 期间没选中(其他入口建的任务)就不处理
|
|
@@ -111,6 +136,22 @@ async function onNewTaskRow(key) {
|
|
|
111
136
|
} finally { convObserver.disconnect(); }
|
|
112
137
|
if (!texts.length) return;
|
|
113
138
|
|
|
139
|
+
// 链接为主的提问(如“实现 <链接> 需求”)对起名模型无从概括:等首轮回答
|
|
140
|
+
// 落定,把回答摘要(去链接、截断)一并作为素材。最多等 60 秒——回答太慢
|
|
141
|
+
// 或没触发识别时按原素材走,不因此丢标题
|
|
142
|
+
if (linkDominant(texts.join('\n'))) {
|
|
143
|
+
const deadline = Date.now() + 60000;
|
|
144
|
+
while (Date.now() < deadline) {
|
|
145
|
+
await sleep(2000);
|
|
146
|
+
if (currentKey() !== key) continue;
|
|
147
|
+
const a = assistantText();
|
|
148
|
+
if (a && a.length > 80) {
|
|
149
|
+
texts.push(`(首轮回答摘要)${a}`);
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
114
155
|
// 失败静默但重试(模型调用偶发失败不应让本次会话永远失去标题):5 秒一次
|
|
115
156
|
// 错开瞬时抖动;20 秒一次兜住“会话刚建的几秒内索引模型信息未写定”
|
|
116
157
|
//(实测新会话 8 秒时解析到的模型不存在,稍后即正常)
|