dsh-code-ui 1.4.0 → 1.5.0
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 +5 -3
- package/lib/client.js +603 -78
- package/lib/index.js +24 -5
- package/lib/vendor/highlight.full.min.js +5306 -5306
- package/lib/vendor/hljs-themes.css +711 -711
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -664,15 +664,22 @@ function rpcHandler(ctx) {
|
|
|
664
664
|
}
|
|
665
665
|
|
|
666
666
|
if (endpoint === "add-reference") {
|
|
667
|
+
const path = args.path || "";
|
|
668
|
+
const kind = args.kind || "cite";
|
|
669
|
+
const lineStart = args.lineStart || null;
|
|
670
|
+
const lineEnd = args.lineEnd || null;
|
|
671
|
+
// 允许重复引用:chip 在输入框句中可视化,重复了用户看得见、可 ✕ 删除,无需 host 去重拦截。
|
|
672
|
+
// (原逻辑曾对同 path+行区间+kind 的未使用引用去重,行内 chip 落地后按用户要求取消)
|
|
667
673
|
const id = "r" + (idSeq++);
|
|
668
674
|
const ref = {
|
|
669
675
|
id,
|
|
670
|
-
path
|
|
676
|
+
path,
|
|
671
677
|
language: args.language || "",
|
|
672
|
-
lineStart
|
|
673
|
-
lineEnd
|
|
678
|
+
lineStart,
|
|
679
|
+
lineEnd,
|
|
674
680
|
text: args.text || "",
|
|
675
|
-
kind
|
|
681
|
+
kind,
|
|
682
|
+
used: false, // 一次性消耗标记:随消息发送后由 use-references 置 true(chip 清空,记录保留)
|
|
676
683
|
createdAt: now(),
|
|
677
684
|
};
|
|
678
685
|
references.push(ref);
|
|
@@ -683,6 +690,17 @@ function rpcHandler(ctx) {
|
|
|
683
690
|
return ok({ references });
|
|
684
691
|
}
|
|
685
692
|
|
|
693
|
+
if (endpoint === "use-references") {
|
|
694
|
+
// 引用一次性消耗:把本条消息附带的引用标记为 used(不删除——AI 在消息发出后才经
|
|
695
|
+
// get_referenced_snippets 读取,删除就读不到了;used 记录保留供用户在【引用/备注】查找)。
|
|
696
|
+
const ids = Array.isArray(args.ids) ? args.ids : [];
|
|
697
|
+
let n = 0;
|
|
698
|
+
for (const r of references) {
|
|
699
|
+
if (!r.used && ids.indexOf(r.id) >= 0) { r.used = true; r.usedAt = now(); n++; }
|
|
700
|
+
}
|
|
701
|
+
return ok({ ok: true, used: n });
|
|
702
|
+
}
|
|
703
|
+
|
|
686
704
|
if (endpoint === "delete-reference") {
|
|
687
705
|
const i = references.findIndex((r) => r.id === args.id);
|
|
688
706
|
if (i >= 0) references.splice(i, 1);
|
|
@@ -911,7 +929,8 @@ function registerSnippetsTool(tools) {
|
|
|
911
929
|
const whole = !r.lineStart;
|
|
912
930
|
const label = r.kind === "translate" ? "翻译请求" : whole ? "文件引用" : "代码引用";
|
|
913
931
|
const loc = (r.path || "") + (whole ? "(整个文件)" : ":" + r.lineStart + "-" + r.lineEnd);
|
|
914
|
-
const
|
|
932
|
+
const num = r.seq ? ",用户 tag 编号 " + r.seq : "";
|
|
933
|
+
const lang = (r.language ? " [" + r.language + "]" : "") + (r.used ? "(已使用" + (r.usedAt ? " " + r.usedAt : "") + num + ")" : "");
|
|
915
934
|
const body = whole
|
|
916
935
|
? "整个文件的引用:请用你的文件读取工具打开上述绝对路径自行读取。"
|
|
917
936
|
: (r.text || "");
|