@copylee/dsh-computer-use 0.4.0 → 0.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 CHANGED
@@ -18,6 +18,7 @@
18
18
  | 你随时可以插手 | 你用键盘打字时 AI 自动暂停,停手 1.5 秒后继续(单按 Shift / Ctrl 等修饰键不算);你切换或打开了别的窗口,AI 下一步不会盲目执行,而是先看新截图再决定。你只是点进 DSH 卡片看对话时不算切换,AI 的按键会自动回到它正在操作的窗口。鼠标移动不会触发,避免误触 |
19
19
  | 文字输入 | Unicode 直接输入,不受输入法状态影响。短文字逐字打出来;长文本默认“流式”:按段落逐段粘贴(代码块不拆开),看得到一段段出现,又不会被 Typora、Obsidian、Word 的自动补全打乱。可在设置里改成逐字输入或一次粘贴。剪贴板文本统一为 CRLF,不丢换行 |
20
20
  | 不弄乱剪贴板 | 插件写入剪贴板的内容不进 Windows 剪贴板历史(Win+V)和云剪贴板;粘贴后按原样恢复你的剪贴板(图片、文件也保留);AI 用 `clipboard` 工具写过剪贴板的,本轮结束后自动还原(期间你自己复制了新内容则不动) |
21
+ | 应用技能 | AI 对各个应用的操作笔记,每个应用一份 Markdown(`~/.dsh/computer-use-skills/`)。AI 摸索清楚一个不熟悉的应用后用 `app_skill` 自己记下来(只记操作规律,不记任务内容),以后 `open_application` 打开该应用时自动附带,不占系统提示。自带 Word、Obsidian、Typora、微信、QQ、记事本六份内置技能;设置页“应用技能”里可以查看、修改、删除、新建,内置技能可覆盖和恢复 |
21
22
  | 打开应用 | `open_application` 同时搜索开始菜单和桌面快捷方式(含公共桌面),便携软件也能按名字打开。已经关到系统托盘的应用(QQ、微信等)会像人一样点托盘图标把窗口叫回来(必要时先展开“显示隐藏的图标”),不会再启动第二个实例、也不会重复登录;你明确要多开时(如微信双开)AI 会用 `new_instance` 另开一个。任务结束时 AI 会收拾现场:关掉自己打开、你不再需要的窗口,`windows tidy` 把原本最小化或在托盘里的应用重新最小化 |
22
23
  | 看不见图的模型 | `ui_elements` 用 Windows UI Automation 列出可点击元素和坐标,纯文本模型也能用 |
23
24
  | 零原生依赖 | 首次使用时用 Windows 自带的 .NET Framework `csc.exe` 编译一个小 helper(约 1 秒,之后缓存),不需要 node-gyp、不受 Electron ABI 影响 |
@@ -54,6 +55,7 @@ dsh plugin --profile web add @copylee/dsh-computer-use@latest
54
55
  |---|---|
55
56
  | `computer` | 单个动作:`screenshot` `left_click` `double_click` `triple_click` `right_click` `middle_click` `mouse_move` `left_click_drag` `left_mouse_down/up` `scroll` `type` `key` `hold_key` `wait` `zoom` `cursor_position`(沿用通用 computer-use 动作命名,模型上手即会) |
56
57
  | `computer_batch` | 顺序执行多个动作,遇错即停,最后回传一张截图 |
58
+ | `app_skill` | 应用技能:`list` 列出、`read` 读取、`append` 追加、`write` 重写某个应用的操作笔记(单份上限 4000 字) |
57
59
  | `open_application` | 按名称(“Chrome”“记事本”“微信”)、exe 路径或网址打开应用;已运行则切到前台,在托盘里则从托盘图标恢复 |
58
60
  | `windows` | 列出窗口(含进程 exe 名)、聚焦 / 最小化 / 最大化 / 还原 / 关闭 |
59
61
  | `ui_elements` | 前台窗口的 UI Automation 元素列表,坐标已换算到截图坐标系 |
@@ -0,0 +1,8 @@
1
+ ---
2
+ app: 记事本
3
+ match: 记事本, Notepad, notepad.exe
4
+ summary: 标签页、核对字数、关闭未保存内容
5
+ ---
6
+ - Windows 11 的记事本是多标签页的:ctrl+n 新建标签页,ctrl+w 关闭当前标签页;重新打开时会恢复上次未保存的标签页,别动用户原有的标签页。
7
+ - 状态栏显示“行 X,列 Y”和字符数,可以用它核对输入是否完整。
8
+ - 关闭有未保存内容的标签页会询问是否保存;任务不要求保存时选“不保存”。
@@ -0,0 +1,11 @@
1
+ ---
2
+ app: Obsidian
3
+ match: Obsidian, obsidian.exe
4
+ summary: 新建笔记、Markdown 打字规律
5
+ ---
6
+ - 新建或打开笔记:ctrl+o 打开快速切换,输入笔记名,Return;不存在的名字会直接创建。ctrl+n 新建无标题笔记。
7
+ - 笔记是库目录下的 .md 纯文本文件,写完可以直接读文件核对内容(不要用写文件代替打字)。
8
+ - 长文本直接用 type 输入(按段落流式粘贴),$...$、$$...$$、**粗体**、标题都按原文进入,不会被自动补全打乱。
9
+ - 列表会自动续行:在“- 甲”后按 Return 会自动出现下一个“- ”。逐行打字时只在第一项写“- ”,后面各项直接写内容;连按两次 Return 退出列表。
10
+ - 标题(## )前最好留一个空行,否则渲染可能和上一段粘在一起。
11
+ - ctrl+f 在当前笔记内查找,ctrl+Home 回到开头。
@@ -0,0 +1,11 @@
1
+ ---
2
+ app: QQ
3
+ match: QQ, QQ.exe
4
+ summary: 从托盘恢复、群文件批量另存
5
+ ---
6
+ - QQ 关闭后缩到系统托盘,用 open_application 恢复。绝对不要再启动一个 QQ(会弹出第二个登录窗),也不要用 shell 显示它的隐藏窗口(界面会卡死)。
7
+ - QQ 的界面不暴露界面元素(ui_elements 为空),只能靠截图操作。
8
+ - 找群:点左上角搜索框输入群名,点结果进入。
9
+ - 群文件:进入群后点聊天窗口右上角的“群文件”图标,会打开单独的“群文件”窗口,文件按上传时间排列。
10
+ - 批量保存:在群文件窗口里选中多个文件,右键选“另存为”,在对话框里输入目标文件夹的完整路径后确认。
11
+ - 已下载的文件在:文档\Tencent Files\<QQ号>\nt_qq\nt_data\File\。
@@ -0,0 +1,9 @@
1
+ ---
2
+ app: Typora
3
+ match: Typora, typora.exe
4
+ summary: Markdown 打字规律、源码模式
5
+ ---
6
+ - 长 Markdown 文本直接用 type 输入:内容按段落粘贴进入,标题、列表、代码块会按原文正确渲染。
7
+ - 逐字敲 Markdown 符号会被自动补全(** 变成 ****、括号成对、列表自动续行),所以不要自己一个字符一个字符地敲格式符号。
8
+ - ctrl+/ 切换源码模式;在源码模式下看到的是原始 Markdown。
9
+ - 保存:ctrl+s,新文件会弹出另存为对话框,alt+n、ctrl+a 后输入完整路径再 Return。
@@ -0,0 +1,11 @@
1
+ ---
2
+ app: 微信
3
+ match: 微信, WeChat, Weixin.exe
4
+ summary: 从托盘恢复、找群、保存群文件
5
+ ---
6
+ - 微信关闭后只是缩到系统托盘,用 open_application 恢复,不要再次启动(会要求重新登录)。
7
+ - 找聊天或群:点左上角搜索框,输入名称,在结果里点对应的群;搜索结果列表可能需要滚动。
8
+ - 看群里的文件:打开群后点右上角“…”(聊天信息),选“查找聊天内容”,再切到“文件”页签,可以按发送人筛选。
9
+ - 保存文件:在文件上右键,选“另存为...”,在对话框里 alt+n、ctrl+a,输入完整路径后 Return。左键单击文件会直接用默认程序打开它。
10
+ - 已接收过的文件在本地缓存:文档\xwechat_files\<微信号目录>\msg\file\<年-月>\,批量归档时可以直接从这里复制。
11
+ - 发送消息、撤回、删除属于不可逆操作,除非用户明确要求,否则先问。
@@ -0,0 +1,10 @@
1
+ ---
2
+ app: Word
3
+ match: Word, winword.exe
4
+ summary: 新建文档、打字排版、另存为
5
+ ---
6
+ - 启动后停在开始页:点“空白文档”(或直接按 Return)进入文档,窗口会换成“文档1 - Word”。
7
+ - 保存:按 F12 直接打开经典“另存为”对话框,alt+n 聚焦文件名框,ctrl+a,输入完整路径(如 C:\Users\<用户>\Desktop\标题.docx),Return。不要点左侧文件夹导航,也不要三击文件名框(会只选中一部分,文件名被拼接)。
8
+ - 打字:以“一、”“1.”开头的段落按 Return 后会触发自动编号和缩进;想保留原样,回车后立刻 ctrl+z 一次撤销自动套用,或写完后 ctrl+a 再 ctrl+q 清除段落格式。
9
+ - 标题格式:ctrl+Home 到开头,shift+End 选中该行,ctrl+b 加粗,ctrl+] 逐级放大字号,ctrl+e 居中。不要去点功能区的字号框再打字,容易把选中的标题文字替换掉。
10
+ - 查找用 ctrl+f(左侧导航窗格),用完按 Escape 关闭。
package/lib/client.js CHANGED
@@ -135,7 +135,7 @@ window.__ModuleLoader__.load({
135
135
  }
136
136
  //#endregion
137
137
  //#region lib/types/client/select.js
138
- const h$1 = react.createElement;
138
+ const h$2 = react.createElement;
139
139
  /** Menu appearance and fixed-position behavior follow dsh-free-search / dsh-proxy. */
140
140
  const selectCss = `
141
141
  .dshcu-select{box-sizing:border-box;width:100%;height:36px;padding:0 12px;display:flex;align-items:center;gap:8px;text-align:left;border:1px solid var(--dsw-alias-border-l4,rgba(127,127,127,.3));border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-3,transparent);color:inherit;font:inherit;font-size:13px;cursor:pointer}
@@ -206,7 +206,7 @@ window.__ModuleLoader__.load({
206
206
  react.useEffect(() => {
207
207
  list.current?.querySelector(`[data-index="${active}"]`)?.scrollIntoView({ block: "nearest" });
208
208
  }, [active, open]);
209
- return h$1("div", { style: { minWidth: 0 } }, h$1("button", {
209
+ return h$2("div", { style: { minWidth: 0 } }, h$2("button", {
210
210
  ref: trigger,
211
211
  type: "button",
212
212
  className: "dshcu-select",
@@ -248,31 +248,31 @@ window.__ModuleLoader__.load({
248
248
  choose(active);
249
249
  }
250
250
  }
251
- }, h$1("span", { style: {
251
+ }, h$2("span", { style: {
252
252
  flex: 1,
253
253
  minWidth: 0,
254
254
  overflow: "hidden",
255
255
  textOverflow: "ellipsis",
256
256
  whiteSpace: "nowrap"
257
- } }, options[selected]?.label), h$1("svg", {
257
+ } }, options[selected]?.label), h$2("svg", {
258
258
  width: 14,
259
259
  height: 14,
260
260
  viewBox: "0 0 16 16",
261
261
  "aria-hidden": true,
262
262
  style: { transform: open ? "rotate(180deg)" : void 0 }
263
- }, h$1("path", {
263
+ }, h$2("path", {
264
264
  d: "M4 6l4 4 4-4",
265
265
  fill: "none",
266
266
  stroke: "currentColor",
267
267
  strokeWidth: 1.6
268
- }))), open ? h$1("div", {
268
+ }))), open ? h$2("div", {
269
269
  ref: list,
270
270
  id: `${id}-list`,
271
271
  role: "listbox",
272
272
  "aria-label": label,
273
273
  className: "dshcu-menu",
274
274
  style: pos
275
- }, ...options.map((option, i) => h$1("div", {
275
+ }, ...options.map((option, i) => h$2("div", {
276
276
  key: option.value,
277
277
  id: `${id}-${i}`,
278
278
  role: "option",
@@ -283,12 +283,12 @@ window.__ModuleLoader__.load({
283
283
  onPointerMove: () => setActive(i),
284
284
  onPointerDown: (e) => e.preventDefault(),
285
285
  onClick: () => choose(i)
286
- }, h$1("span", { style: { flex: 1 } }, option.label), h$1("span", { style: { width: 14 } }, i === selected ? h$1("svg", {
286
+ }, h$2("span", { style: { flex: 1 } }, option.label), h$2("span", { style: { width: 14 } }, i === selected ? h$2("svg", {
287
287
  width: 14,
288
288
  height: 14,
289
289
  viewBox: "0 0 16 16",
290
290
  "aria-hidden": true
291
- }, h$1("path", {
291
+ }, h$2("path", {
292
292
  d: "M3.5 8.5 6.5 11.5 12.5 4.5",
293
293
  fill: "none",
294
294
  stroke: "currentColor",
@@ -298,6 +298,245 @@ window.__ModuleLoader__.load({
298
298
  })) : null)))) : null);
299
299
  }
300
300
  //#endregion
301
+ //#region lib/types/client/skills-card.js
302
+ /**
303
+ * "应用技能" card: the per-app notes the agent keeps (see ../skills.ts). The
304
+ * user can read, edit, add and delete them here; built-in skills can be
305
+ * overridden and restored.
306
+ */
307
+ const SKILLS_ROUTE = "/api/dsh-computer-use/skills";
308
+ const MAX_CHARS = 4e3;
309
+ const h$1 = react.createElement;
310
+ function SkillsCard({ S }) {
311
+ const [skills, setSkills] = react.useState(null);
312
+ const [dir, setDir] = react.useState("");
313
+ const [draft, setDraft] = react.useState(null);
314
+ const [busy, setBusy] = react.useState(false);
315
+ const [note, setNote] = react.useState(null);
316
+ const call = react.useCallback(async (body) => {
317
+ setBusy(true);
318
+ try {
319
+ const result = await (await fetch(SKILLS_ROUTE, body ? {
320
+ method: "POST",
321
+ credentials: "same-origin",
322
+ headers: { "content-type": "application/json" },
323
+ body: JSON.stringify(body)
324
+ } : { credentials: "same-origin" })).json();
325
+ if (!result.ok) throw new Error(result.error ?? "请求失败");
326
+ setSkills(result.skills ?? []);
327
+ setDir(result.dir ?? "");
328
+ return true;
329
+ } catch (error) {
330
+ setNote({
331
+ kind: "error",
332
+ text: error.message
333
+ });
334
+ return false;
335
+ } finally {
336
+ setBusy(false);
337
+ }
338
+ }, []);
339
+ react.useEffect(() => {
340
+ call();
341
+ }, [call]);
342
+ const edit = (skill) => {
343
+ setNote(null);
344
+ setDraft({
345
+ id: skill.id,
346
+ app: skill.app,
347
+ match: skill.match.join(", "),
348
+ summary: skill.summary,
349
+ content: skill.content,
350
+ isNew: false
351
+ });
352
+ };
353
+ const save = async () => {
354
+ if (!draft) return;
355
+ setNote(null);
356
+ if (await call({
357
+ op: "save",
358
+ id: draft.isNew ? "" : draft.id,
359
+ app: draft.app,
360
+ match: draft.match,
361
+ summary: draft.summary,
362
+ content: draft.content
363
+ })) {
364
+ setDraft(null);
365
+ setNote({
366
+ kind: "ok",
367
+ text: "已保存"
368
+ });
369
+ }
370
+ };
371
+ const remove = async (skill) => {
372
+ setNote(null);
373
+ if (await call({
374
+ op: "delete",
375
+ id: skill.id
376
+ })) {
377
+ if (draft?.id === skill.id) setDraft(null);
378
+ setNote({
379
+ kind: "ok",
380
+ text: `已删除“${skill.app}”`
381
+ });
382
+ }
383
+ };
384
+ const reset = async (skill) => {
385
+ setNote(null);
386
+ if (await call({
387
+ op: "reset",
388
+ id: skill.id
389
+ })) {
390
+ if (draft?.id === skill.id) setDraft(null);
391
+ setNote({
392
+ kind: "ok",
393
+ text: `已恢复“${skill.app}”的内置版本`
394
+ });
395
+ }
396
+ };
397
+ const row = {
398
+ display: "flex",
399
+ gap: 10,
400
+ alignItems: "center",
401
+ padding: "8px 0",
402
+ borderTop: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.18))"
403
+ };
404
+ const small = {
405
+ ...S.secondary,
406
+ padding: "4px 10px",
407
+ fontSize: 12
408
+ };
409
+ const tag = {
410
+ fontSize: 11,
411
+ padding: "1px 7px",
412
+ borderRadius: 999,
413
+ border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.3))",
414
+ color: "var(--dsw-alias-label-tertiary, #888)",
415
+ whiteSpace: "nowrap"
416
+ };
417
+ const invalid = draft !== null && (draft.app.trim() === "" || draft.content.trim() === "" || draft.content.length > MAX_CHARS);
418
+ return h$1("section", { style: S.card }, h$1("h3", { style: S.cardTitle }, "应用技能"), h$1("p", { style: S.hint }, "AI 对各个应用的操作笔记:每个应用一份,AI 摸索清楚一个不熟悉的应用后会自己记下来,以后打开这个应用时自动读取,不占用系统提示。你可以在这里查看、修改、删除或新建。"), skills === null ? h$1("p", { style: S.hint }, busy ? "正在读取…" : "无法读取应用技能。") : skills.length === 0 ? h$1("p", { style: S.hint }, "还没有应用技能。") : h$1("div", null, ...skills.map((skill) => h$1("div", {
419
+ key: skill.id,
420
+ style: row
421
+ }, h$1("div", { style: {
422
+ flex: 1,
423
+ minWidth: 0
424
+ } }, h$1("div", { style: {
425
+ fontSize: 13,
426
+ fontWeight: 600,
427
+ display: "flex",
428
+ gap: 8,
429
+ alignItems: "center"
430
+ } }, skill.app, h$1("span", { style: tag }, skill.source === "builtin" ? "内置" : skill.overrides ? "已修改" : "AI / 自定义")), h$1("div", { style: {
431
+ ...S.hint,
432
+ overflow: "hidden",
433
+ textOverflow: "ellipsis",
434
+ whiteSpace: "nowrap"
435
+ } }, `${skill.summary || "(无摘要)"} · ${skill.content.length} 字`)), h$1("button", {
436
+ type: "button",
437
+ style: small,
438
+ disabled: busy,
439
+ onClick: () => edit(skill)
440
+ }, "查看 / 编辑"), skill.overrides ? h$1("button", {
441
+ type: "button",
442
+ style: small,
443
+ disabled: busy,
444
+ onClick: () => {
445
+ reset(skill);
446
+ }
447
+ }, "恢复内置") : null, h$1("button", {
448
+ type: "button",
449
+ style: small,
450
+ disabled: busy,
451
+ onClick: () => {
452
+ remove(skill);
453
+ }
454
+ }, "删除")))), draft === null ? null : h$1("div", { style: {
455
+ display: "grid",
456
+ gap: 10,
457
+ paddingTop: 4
458
+ } }, h$1("div", { style: S.grid2 }, h$1("label", { style: S.label }, "应用名称", h$1("input", {
459
+ style: S.input,
460
+ value: draft.app,
461
+ disabled: !draft.isNew,
462
+ maxLength: 60,
463
+ placeholder: "如 Obsidian",
464
+ onChange: (e) => setDraft({
465
+ ...draft,
466
+ app: e.target.value
467
+ })
468
+ })), h$1("label", { style: S.label }, "匹配的程序(逗号分隔)", h$1("input", {
469
+ style: S.input,
470
+ value: draft.match,
471
+ maxLength: 200,
472
+ placeholder: "如 Obsidian, obsidian.exe",
473
+ onChange: (e) => setDraft({
474
+ ...draft,
475
+ match: e.target.value
476
+ })
477
+ }))), h$1("label", { style: S.label }, "摘要", h$1("input", {
478
+ style: S.input,
479
+ value: draft.summary,
480
+ maxLength: 80,
481
+ placeholder: "几个词说明这份技能讲什么",
482
+ onChange: (e) => setDraft({
483
+ ...draft,
484
+ summary: e.target.value
485
+ })
486
+ })), h$1("label", { style: S.label }, `内容(${draft.content.length} / ${MAX_CHARS} 字)`, h$1("textarea", {
487
+ style: {
488
+ ...S.input,
489
+ minHeight: 200,
490
+ resize: "vertical",
491
+ fontFamily: "inherit",
492
+ lineHeight: 1.55
493
+ },
494
+ value: draft.content,
495
+ placeholder: "- 一条一条写操作规律:入口在哪、快捷键、容易踩的坑",
496
+ onChange: (e) => setDraft({
497
+ ...draft,
498
+ content: e.target.value
499
+ })
500
+ })), h$1("div", { style: S.actions }, h$1("button", {
501
+ type: "button",
502
+ style: {
503
+ ...S.primary,
504
+ opacity: busy || invalid ? .5 : 1
505
+ },
506
+ disabled: busy || invalid,
507
+ onClick: () => {
508
+ save();
509
+ }
510
+ }, "保存技能"), h$1("button", {
511
+ type: "button",
512
+ style: S.secondary,
513
+ disabled: busy,
514
+ onClick: () => setDraft(null)
515
+ }, "取消"), draft.content.length > MAX_CHARS ? h$1("span", { style: S.error }, "内容过长,请精简") : null)), h$1("div", { style: S.actions }, draft === null ? h$1("button", {
516
+ type: "button",
517
+ style: S.secondary,
518
+ disabled: busy,
519
+ onClick: () => {
520
+ setNote(null);
521
+ setDraft({
522
+ id: "",
523
+ app: "",
524
+ match: "",
525
+ summary: "",
526
+ content: "",
527
+ isNew: true
528
+ });
529
+ }
530
+ }, "新建技能") : null, h$1("button", {
531
+ type: "button",
532
+ style: S.secondary,
533
+ disabled: busy,
534
+ onClick: () => {
535
+ call();
536
+ }
537
+ }, "刷新"), note === null ? null : h$1("span", { style: note.kind === "ok" ? S.ok : S.error }, note.text)), dir ? h$1("p", { style: S.hint }, `保存位置:${dir}(每个应用一个 .md 文件,也可以直接用编辑器改)。删除内置技能后,新建同名技能即可重新启用。`) : null);
538
+ }
539
+ //#endregion
301
540
  //#region lib/types/client/index.js
302
541
  /**
303
542
  * Browser half: the "电脑控制" (Computer use) section in Settings. It reads the
@@ -876,7 +1115,7 @@ window.__ModuleLoader__.load({
876
1115
  error: errors.jpegQuality,
877
1116
  disabled,
878
1117
  onChange: (value) => edit("jpegQuality", value)
879
- })), h("p", { style: S.hint }, "截图越大越清晰、点得越准,但每张图消耗的 token 也越多。默认值(最长边 1366、1.15 百万像素)适合大多数模型。")), h("section", { style: S.card }, h("h3", { style: S.cardTitle }, "截图缓存"), h("p", { style: S.hint }, cache === null ? cacheBusy ? "正在统计…" : "无法统计截图缓存。" : !cache.ok ? `统计失败:${cache.error ?? ""}` : `本插件的截图共 ${cache.count} 张,占用 ${mb(cache.bytes)};其中 ${cache.orphans} 张(${mb(cache.orphanBytes)})所属会话已删除,可以安全清理。`), h("p", { style: S.hint }, "截图作为附件保存在会话历史里。仍在会话中的截图不会被删除:删除后继续那个会话会直接报错。删除会话后,它留下的截图会在启动 DeepSeek Harness 几分钟后及之后每 12 小时自动清理,也可以在这里立即清理。"), h("div", { style: S.actions }, h("button", {
1118
+ })), h("p", { style: S.hint }, "截图越大越清晰、点得越准,但每张图消耗的 token 也越多。默认值(最长边 1366、1.15 百万像素)适合大多数模型。")), h(SkillsCard, { S }), h("section", { style: S.card }, h("h3", { style: S.cardTitle }, "截图缓存"), h("p", { style: S.hint }, cache === null ? cacheBusy ? "正在统计…" : "无法统计截图缓存。" : !cache.ok ? `统计失败:${cache.error ?? ""}` : `本插件的截图共 ${cache.count} 张,占用 ${mb(cache.bytes)};其中 ${cache.orphans} 张(${mb(cache.orphanBytes)})所属会话已删除,可以安全清理。`), h("p", { style: S.hint }, "截图作为附件保存在会话历史里。仍在会话中的截图不会被删除:删除后继续那个会话会直接报错。删除会话后,它留下的截图会在启动 DeepSeek Harness 几分钟后及之后每 12 小时自动清理,也可以在这里立即清理。"), h("div", { style: S.actions }, h("button", {
880
1119
  type: "button",
881
1120
  style: {
882
1121
  ...S.secondary,
package/lib/index.js CHANGED
@@ -3,7 +3,7 @@ import { createHash, randomUUID } from "node:crypto";
3
3
  import z from "@deepseek-ai/schemastery";
4
4
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
5
5
  import { execFile, spawn } from "node:child_process";
6
- import { existsSync } from "node:fs";
6
+ import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
7
7
  import { chmod, mkdir, readFile, readdir, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
8
8
  import { homedir, tmpdir } from "node:os";
9
9
  import { join } from "node:path";
@@ -1616,7 +1616,7 @@ var OverlayController = class {
1616
1616
  //#region lib/types/prompt.js
1617
1617
  function promptText(mode) {
1618
1618
  return `# Computer use (Windows desktop)
1619
- You can see and operate the user's Windows computer with the computer, computer_batch, open_application, windows, ui_elements and clipboard tools.
1619
+ You can see and operate the user's Windows computer with the computer, computer_batch, open_application, windows, ui_elements, clipboard and app_skill tools.
1620
1620
  ${mode === "per-app" ? "- Before acting on an app, call request_access once with every app the task needs; the user approves it. Input to apps that are not granted is refused.\n" : ""}- Start with a screenshot (computer action "screenshot") unless you just received one. All coordinates are pixels of the latest screenshot; the plugin converts them for DPI and scaling.
1621
1621
  - Open or switch apps with open_application (by name; it also finds desktop shortcuts) rather than hunting through the taskbar or Start menu or starting GUI apps from a shell. Use windows to see which windows exist; each line shows the process .exe. Apps closed to the system tray (QQ, 微信...) are still running: open_application restores them from their tray icon. Do not start a second copy of a running app unless the user explicitly asks for one (then pass new_instance: true), and never show or kill its hidden windows from a shell (Electron / Qt apps freeze, and a second QQ / WeChat asks for another login).
1622
1622
  - When the task is done, tidy up: close windows and dialogs you opened that the user no longer needs (keep the one showing the result they asked for), and call windows tidy to minimize again the apps that were minimized or in the tray before you started. Never close windows the user already had open.
@@ -1625,6 +1625,7 @@ ${mode === "per-app" ? "- Before acting on an app, call request_access once with
1625
1625
  - Prefer reliable keyboard shortcuts (ctrl+l for a browser address bar, ctrl+s, alt+F4, ctrl+t). Click the center of targets. When text is too small to read, zoom once on a generous region that contains everything you need (zooming step by step wastes calls).
1626
1626
  - Actions return a fresh screenshot taken once the screen stops changing (page loads included, up to a few seconds), so you rarely need wait. If something is still loading, use wait: it also returns a screenshot, so never follow it with a separate screenshot call.
1627
1627
  - When the user asks you to write something in an app, enter it there with type, even long or multi-line Markdown: the user watches it appear (long text is streamed in paragraph by paragraph, literally, without the editor's auto-formatting getting in the way). Do not write the file from a shell and reopen it instead, and do not put text on the clipboard with shell commands (Set-Clipboard, clip): that clutters the user's clipboard history.
1628
+ - App skills: open_application returns your saved notes for the app it opens; follow them instead of rediscovering how the app behaves. After working out an unfamiliar app (or finding a note wrong), record the reusable part with app_skill rather than in general memory.
1628
1629
  - Saving: in any Save As dialog do not click through folders; press alt+n (file name box), ctrl+a, type the full path including the file name, then Return. Office apps: F12 opens that classic dialog directly. To check a saved file, look at the exact path; never search a whole drive or user profile recursively.
1629
1630
  - Be efficient: every tool call costs the user several seconds. Put predictable sequences (click a field, type, press Return; open a menu and pick an item you can already see) into one computer_batch. Avoid shell commands for things you can see on screen.
1630
1631
  - To see more of a page or list, scroll (action "scroll" with coordinate over the area, scroll_direction, scroll_amount 5-10) instead of hunting with zoom; for long web pages Page Down / End keys also work.
@@ -1633,6 +1634,184 @@ ${mode === "per-app" ? "- Before acting on an app, call request_access once with
1633
1634
  - The user sees an orange border and can press Esc to pause you at any time. If they pause, type on the keyboard or switch windows, you wait; when an action reports it was not performed, re-check the screen instead of repeating it blindly.`;
1634
1635
  }
1635
1636
  //#endregion
1637
+ //#region lib/types/skills.js
1638
+ /**
1639
+ * App skills: short notes on how to operate one application, kept by the agent
1640
+ * (and editable by the user) as one Markdown file per app. Only a one-line
1641
+ * catalog goes into the system prompt; the notes themselves are handed over
1642
+ * when the app is opened, or read on demand.
1643
+ *
1644
+ * File format (front matter is optional):
1645
+ * ---
1646
+ * app: Obsidian
1647
+ * match: obsidian.exe, obsidian
1648
+ * summary: 打字规律、新建笔记
1649
+ * ---
1650
+ * - notes...
1651
+ *
1652
+ * The plugin ships a few built-in skills; a user file with the same id
1653
+ * overrides one, and `disabled: true` hides it.
1654
+ */
1655
+ /** Notes longer than this must be condensed before more is added. */
1656
+ const SKILL_MAX_CHARS = 4e3;
1657
+ /** Host processes shared by many apps: never a way to recognise one app. */
1658
+ const GENERIC_HOSTS = /^(applicationframehost|explorer|msedgewebview2|javaw?|python\w*|electron)(\.exe)?$/i;
1659
+ function skillId(app) {
1660
+ return app.trim().toLowerCase().replace(/\.exe$/, "").replace(/[\\/:*?"<>|\s.]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "app";
1661
+ }
1662
+ function parseSkill(text, fallbackApp) {
1663
+ const out = {
1664
+ app: fallbackApp,
1665
+ match: [],
1666
+ summary: "",
1667
+ content: text.trim(),
1668
+ disabled: false
1669
+ };
1670
+ const front = /^?---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(text);
1671
+ if (!front) return out;
1672
+ out.content = text.slice(front[0].length).trim();
1673
+ for (const line of front[1].split(/\r?\n/)) {
1674
+ const pair = /^([a-z]+)\s*:\s*(.*)$/i.exec(line.trim());
1675
+ if (!pair) continue;
1676
+ const key = pair[1].toLowerCase();
1677
+ const value = pair[2].trim();
1678
+ if (key === "app" && value) out.app = value;
1679
+ else if (key === "match") out.match = value.split(/[,,]/).map((item) => item.trim()).filter(Boolean);
1680
+ else if (key === "summary") out.summary = value;
1681
+ else if (key === "disabled") out.disabled = value === "true";
1682
+ }
1683
+ return out;
1684
+ }
1685
+ function formatSkill(skill, disabled = false) {
1686
+ const head = [
1687
+ `app: ${skill.app}`,
1688
+ `match: ${skill.match.join(", ")}`,
1689
+ `summary: ${skill.summary.replace(/\r?\n/g, " ")}`
1690
+ ];
1691
+ if (disabled) head.push("disabled: true");
1692
+ return `---\n${head.join("\n")}\n---\n${skill.content.trim()}\n`;
1693
+ }
1694
+ var SkillStore = class {
1695
+ builtinDir;
1696
+ userDir;
1697
+ constructor(builtinDir, userDir = join(process.env.DSH_HOME ?? join(homedir(), ".dsh"), "computer-use-skills")) {
1698
+ this.builtinDir = builtinDir;
1699
+ this.userDir = userDir;
1700
+ }
1701
+ load(dir, source) {
1702
+ const map = /* @__PURE__ */ new Map();
1703
+ if (!existsSync(dir)) return map;
1704
+ for (const name of readdirSync(dir)) {
1705
+ if (!name.toLowerCase().endsWith(".md")) continue;
1706
+ try {
1707
+ const path = join(dir, name);
1708
+ const parsed = parseSkill(readFileSync(path, "utf8"), name.slice(0, -3));
1709
+ const id = skillId(name.slice(0, -3));
1710
+ map.set(id, {
1711
+ id,
1712
+ app: parsed.app,
1713
+ match: parsed.match.length > 0 ? parsed.match : [parsed.app],
1714
+ summary: parsed.summary,
1715
+ content: parsed.content,
1716
+ source,
1717
+ overrides: false,
1718
+ updatedAt: statSync(path).mtimeMs,
1719
+ disabled: parsed.disabled
1720
+ });
1721
+ } catch {}
1722
+ }
1723
+ return map;
1724
+ }
1725
+ /** Every active skill, user files first in precedence, sorted by app name. */
1726
+ list() {
1727
+ const builtin = this.load(this.builtinDir, "builtin");
1728
+ const user = this.load(this.userDir, "user");
1729
+ const out = [];
1730
+ for (const [id, skill] of user) {
1731
+ if (skill.disabled) continue;
1732
+ const { disabled: _disabled, ...rest } = skill;
1733
+ out.push({
1734
+ ...rest,
1735
+ overrides: builtin.has(id)
1736
+ });
1737
+ }
1738
+ for (const [id, skill] of builtin) {
1739
+ if (user.has(id)) continue;
1740
+ const { disabled: _disabled, ...rest } = skill;
1741
+ out.push(rest);
1742
+ }
1743
+ return out.sort((a, b) => a.app.localeCompare(b.app, "zh-CN"));
1744
+ }
1745
+ get(id) {
1746
+ const wanted = skillId(id);
1747
+ return this.list().find((skill) => skill.id === wanted);
1748
+ }
1749
+ /** The skill for an app by name, or for a window by its executable. */
1750
+ find(name, win) {
1751
+ const skills = this.list();
1752
+ const wanted = skillId(name);
1753
+ return skills.find((skill) => skill.id === wanted) ?? skills.find((skill) => skill.match.some((item) => skillId(item) === wanted)) ?? (win ? skills.find((skill) => skill.match.some((item) => !GENERIC_HOSTS.test(item) && appMatches(item, win))) : void 0);
1754
+ }
1755
+ /** One line per skill for the system prompt. */
1756
+ catalog() {
1757
+ return this.list().map((skill) => `${skill.app}${skill.summary ? ` (${skill.summary})` : ""}`).join("; ");
1758
+ }
1759
+ save(input, id = skillId(input.app)) {
1760
+ const app = input.app.trim();
1761
+ if (app === "") throw new Error("app is required.");
1762
+ const content = input.content.trim();
1763
+ if (content === "") throw new Error("content is empty.");
1764
+ if (content.length > 4e3) throw new Error(`The skill would be ${content.length} characters; the limit is ${SKILL_MAX_CHARS}. Condense it (merge duplicates, drop one-off details) and write it again.`);
1765
+ const previous = this.get(id);
1766
+ const match = [...new Set([
1767
+ ...input.match ?? [],
1768
+ ...previous?.match ?? [],
1769
+ app
1770
+ ].map((item) => item.trim()).filter((item) => item !== "" && !GENERIC_HOSTS.test(item)))];
1771
+ const summary = (input.summary ?? previous?.summary ?? "").trim().slice(0, 80);
1772
+ mkdirSync(this.userDir, { recursive: true });
1773
+ const path = join(this.userDir, `${skillId(id)}.md`);
1774
+ const tmp = `${path}.tmp`;
1775
+ writeFileSync(tmp, formatSkill({
1776
+ app,
1777
+ match,
1778
+ summary,
1779
+ content
1780
+ }), "utf8");
1781
+ renameSync(tmp, path);
1782
+ return this.get(id);
1783
+ }
1784
+ append(app, text, extra = {}) {
1785
+ const previous = this.find(app);
1786
+ const content = previous ? `${previous.content}\n${text.trim()}` : text.trim();
1787
+ return this.save({
1788
+ app: previous?.app ?? app,
1789
+ content,
1790
+ ...extra
1791
+ }, previous?.id ?? skillId(app));
1792
+ }
1793
+ /** Delete a user skill; a built-in one is hidden by a disabled override. */
1794
+ remove(id) {
1795
+ const wanted = skillId(id);
1796
+ const path = join(this.userDir, `${wanted}.md`);
1797
+ const builtin = this.load(this.builtinDir, "builtin").get(wanted);
1798
+ if (builtin) {
1799
+ mkdirSync(this.userDir, { recursive: true });
1800
+ writeFileSync(path, formatSkill({
1801
+ app: builtin.app,
1802
+ match: builtin.match,
1803
+ summary: builtin.summary,
1804
+ content: ""
1805
+ }, true), "utf8");
1806
+ } else if (existsSync(path)) unlinkSync(path);
1807
+ }
1808
+ /** Drop the user's override so the built-in skill applies again. */
1809
+ reset(id) {
1810
+ const path = join(this.userDir, `${skillId(id)}.md`);
1811
+ if (existsSync(path)) unlinkSync(path);
1812
+ }
1813
+ };
1814
+ //#endregion
1636
1815
  //#region lib/types/settings.js
1637
1816
  /** The Loader entry id (settings namespace); see cordis.patch.yml. */
1638
1817
  const ENTRY_ID = "copylee-computer-use";
@@ -1684,6 +1863,7 @@ const STATUS_ROUTE = "/api/dsh-computer-use/status";
1684
1863
  const PREVIEW_ROUTE = "/api/dsh-computer-use/preview";
1685
1864
  const SCREENSHOTS_ROUTE = "/api/dsh-computer-use/screenshots";
1686
1865
  const SCREENSHOTS_CLEAN_ROUTE = "/api/dsh-computer-use/screenshots/clean";
1866
+ const SKILLS_ROUTE = "/api/dsh-computer-use/skills";
1687
1867
  function json(res, status, body) {
1688
1868
  res.writeHead(status, {
1689
1869
  "content-type": "application/json; charset=utf-8",
@@ -1792,6 +1972,54 @@ function screenshotsCleanRoute(cache) {
1792
1972
  }
1793
1973
  };
1794
1974
  }
1975
+ async function body(req) {
1976
+ const chunks = [];
1977
+ let size = 0;
1978
+ for await (const chunk of req) {
1979
+ size += chunk.length;
1980
+ if (size > 2e5) throw new Error("request too large");
1981
+ chunks.push(chunk);
1982
+ }
1983
+ const parsed = chunks.length === 0 ? {} : JSON.parse(Buffer.concat(chunks).toString("utf8"));
1984
+ return parsed !== null && typeof parsed === "object" ? parsed : {};
1985
+ }
1986
+ /** App skills for the settings page: GET lists them; POST { op: 'save' | 'delete' | 'reset', ... } changes one. */
1987
+ function skillsRoute(skills) {
1988
+ return async (req, res) => {
1989
+ if (req.method === "POST") {
1990
+ const input = await body(req);
1991
+ const id = typeof input.id === "string" ? input.id : "";
1992
+ try {
1993
+ if (input.op === "delete") skills.remove(id);
1994
+ else if (input.op === "reset") skills.reset(id);
1995
+ else if (input.op === "save") skills.save({
1996
+ app: String(input.app ?? ""),
1997
+ match: String(input.match ?? "").split(/[,,]/).map((item) => item.trim()).filter(Boolean),
1998
+ summary: String(input.summary ?? ""),
1999
+ content: String(input.content ?? "")
2000
+ }, id || void 0);
2001
+ else {
2002
+ json(res, 400, {
2003
+ ok: false,
2004
+ error: "unknown op"
2005
+ });
2006
+ return;
2007
+ }
2008
+ } catch (error) {
2009
+ json(res, 200, {
2010
+ ok: false,
2011
+ error: error instanceof Error ? error.message : String(error)
2012
+ });
2013
+ return;
2014
+ }
2015
+ }
2016
+ json(res, 200, {
2017
+ ok: true,
2018
+ dir: skills.userDir,
2019
+ skills: skills.list()
2020
+ });
2021
+ };
2022
+ }
1795
2023
  //#endregion
1796
2024
  //#region lib/types/screenshots.js
1797
2025
  /**
@@ -7909,16 +8137,35 @@ function createTools(host) {
7909
8137
  await setTimeout$1(250, void 0, { signal: call.signal });
7910
8138
  const now = await computer.foreground();
7911
8139
  if (now && now.hwnd !== before?.hwnd && !isHostWindow(now) && !isTransientShell(now) && (now.exe.toLowerCase() !== "explorer.exe" || now.className === "CabinetWClass")) break;
8140
+ if (i >= 4 && i % 4 === 0 && !isUri) {
8141
+ const opened = (await computer.windows()).find((win) => !isHostWindow(win) && appMatches(name, win));
8142
+ if (opened) {
8143
+ await computer.focus(opened).catch(() => void 0);
8144
+ break;
8145
+ }
8146
+ }
7912
8147
  }
7913
8148
  }
7914
8149
  const fg = await computer.foreground();
7915
8150
  if (fg && !isHostWindow(fg) && settings.accessMode === "per-app" && (computer.access.missing(call.session, [appName]).length === 0 || isUrl)) computer.access.grant(call.session, [fg.exe]);
7916
8151
  await computer.settle(call.signal);
7917
8152
  const shot = call.vision ? await computer.screenshot() : void 0;
7918
- return withShot(host, `${how} ${await computer.describeForeground()}`, shot, call);
8153
+ return withShot(host, `${how} ${await computer.describeForeground()}${skillNote(call.session, name, fg)}`, shot, call);
7919
8154
  },
7920
8155
  presentCall: (args) => card(`打开应用 · ${args.name ?? ""}`)
7921
8156
  }));
8157
+ /** Skills already handed to a session, so each is attached once. */
8158
+ const told = /* @__PURE__ */ new Map();
8159
+ /** The app's skill, appended to open_application's result the first time in a session. */
8160
+ function skillNote(session, name, win) {
8161
+ const skill = host.skills?.find(name, win && !isHostWindow(win) ? win : void 0);
8162
+ if (!skill) return host.skills ? "\n(No app skill for this app yet: if you have to work out how it behaves, record the reusable part with app_skill append when you are done.)" : "";
8163
+ let seen = told.get(session);
8164
+ if (!seen) told.set(session, seen = /* @__PURE__ */ new Set());
8165
+ if (seen.has(skill.id)) return "";
8166
+ seen.add(skill.id);
8167
+ return `\n\nYour skill notes for ${skill.app} (app_skill; correct them if they turn out wrong):\n${skill.content}`;
8168
+ }
7922
8169
  /** Put back what the task changed: re-minimize restored windows, report the ones it opened. */
7923
8170
  async function tidy(call) {
7924
8171
  await computer.overlay.begin(call.agent, "整理窗口");
@@ -8118,6 +8365,71 @@ function createTools(host) {
8118
8365
  },
8119
8366
  presentCall: (args) => card(`请求操控 · ${(args.apps ?? []).join("、")}`)
8120
8367
  }));
8368
+ if (host.skills) {
8369
+ const skills = host.skills;
8370
+ tools.push(defineTool({
8371
+ name: "app_skill",
8372
+ description: `Your notes on how to operate specific apps (one skill per app, kept across sessions; the user can edit them). open_application already returns the skill of the app it opens. Use "list" to see which apps have one, "read" for an app you reach another way, and "append" / "write" to record what you worked out about an unfamiliar app: reusable operating knowledge only (where things are, shortcuts, quirks, what failed and what works), never task content, personal data or pixel coordinates (they change with the window). Keep each skill under ${SKILL_MAX_CHARS} characters; rewrite it with "write" when it gets long or wrong.`,
8373
+ parameters: {
8374
+ action: {
8375
+ type: "string",
8376
+ enum: [
8377
+ "list",
8378
+ "read",
8379
+ "append",
8380
+ "write"
8381
+ ],
8382
+ required: true
8383
+ },
8384
+ app: {
8385
+ type: "string",
8386
+ description: "App name, e.g. \"Obsidian\" (read / append / write)."
8387
+ },
8388
+ content: {
8389
+ type: "string",
8390
+ description: "Markdown bullet points: the lines to add (append) or the whole skill (write)."
8391
+ },
8392
+ summary: {
8393
+ type: "string",
8394
+ description: "A few words on what the skill covers, shown in the list (write, or the first append)."
8395
+ }
8396
+ },
8397
+ output,
8398
+ isConcurrencySafe: () => false,
8399
+ async execute(args) {
8400
+ const { action, app, content, summary } = args;
8401
+ if (action === "list") {
8402
+ const rows = skills.list();
8403
+ return { text: rows.length === 0 ? "No app skills yet." : rows.map((skill) => `${skill.app}${skill.summary ? ` — ${skill.summary}` : ""} (${skill.content.length} chars)`).join("\n") };
8404
+ }
8405
+ const name = String(app ?? "").trim();
8406
+ if (name === "") throw new Error("app is required.");
8407
+ if (action === "read") {
8408
+ const skill = skills.find(name, await computer.foreground().catch(() => void 0));
8409
+ return { text: skill ? `Skill for ${skill.app}:\n${skill.content}` : `No skill for "${name}" yet. If you work out how this app behaves, record it with app_skill append.` };
8410
+ }
8411
+ const text = String(content ?? "").trim();
8412
+ if (text === "") throw new Error("content is required.");
8413
+ const fg = await computer.foreground().catch(() => void 0);
8414
+ const extra = {
8415
+ match: fg && !isHostWindow(fg) && appMatches(name, fg) && !/^applicationframehost/i.test(fg.exe) ? [fg.exe] : [],
8416
+ ...summary ? { summary } : {}
8417
+ };
8418
+ const saved = action === "write" ? skills.save({
8419
+ app: name,
8420
+ content: text,
8421
+ ...extra
8422
+ }, skills.find(name)?.id) : skills.append(name, text, extra);
8423
+ return { text: `Skill for ${saved.app} saved (${saved.content.length} of ${SKILL_MAX_CHARS} characters).` };
8424
+ },
8425
+ presentCall: (args) => card(`应用技能 · ${{
8426
+ list: "列表",
8427
+ read: "读取",
8428
+ append: "记录",
8429
+ write: "重写"
8430
+ }[args.action ?? ""] ?? ""}${args.app ? ` · ${args.app}` : ""}`)
8431
+ }));
8432
+ }
8121
8433
  tools.push(defineTool({
8122
8434
  name: "list_granted_applications",
8123
8435
  description: "List the apps you may control in this session.",
@@ -8286,8 +8598,10 @@ function apply(ctx, config = {}) {
8286
8598
  clearInterval(every);
8287
8599
  };
8288
8600
  }, "computer-use: screenshot cleanup");
8601
+ const skills = new SkillStore(helperAssetPath("skills"));
8289
8602
  const tools = createTools({
8290
8603
  computer,
8604
+ skills,
8291
8605
  async saveImage(shot, fileName) {
8292
8606
  const ref = await attachments().saveImage({
8293
8607
  data: shot.data,
@@ -8403,6 +8717,7 @@ function apply(ctx, config = {}) {
8403
8717
  route(PREVIEW_ROUTE, previewRoute(helper, settings, overlay, iconPath));
8404
8718
  route(SCREENSHOTS_ROUTE, screenshotsRoute(screenshots));
8405
8719
  route(SCREENSHOTS_CLEAN_ROUTE, screenshotsCleanRoute(screenshots));
8720
+ route(SKILLS_ROUTE, skillsRoute(skills));
8406
8721
  });
8407
8722
  ctx.inject(["systemPrompt"], (promptCtx) => {
8408
8723
  let registered;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * "应用技能" card: the per-app notes the agent keeps (see ../skills.ts). The
3
+ * user can read, edit, add and delete them here; built-in skills can be
4
+ * overridden and restored.
5
+ */
6
+ import * as React from 'react';
7
+ export declare function SkillsCard({ S }: {
8
+ S: Record<string, React.CSSProperties>;
9
+ }): React.ReactElement;
@@ -8,10 +8,12 @@ import type { Settings } from './computer.js';
8
8
  import type { HelperLike } from './helper-client.js';
9
9
  import type { OverlayController } from './overlay.js';
10
10
  import type { ScreenshotCache } from './screenshots.js';
11
+ import type { SkillStore } from './skills.js';
11
12
  export declare const STATUS_ROUTE = "/api/dsh-computer-use/status";
12
13
  export declare const PREVIEW_ROUTE = "/api/dsh-computer-use/preview";
13
14
  export declare const SCREENSHOTS_ROUTE = "/api/dsh-computer-use/screenshots";
14
15
  export declare const SCREENSHOTS_CLEAN_ROUTE = "/api/dsh-computer-use/screenshots/clean";
16
+ export declare const SKILLS_ROUTE = "/api/dsh-computer-use/skills";
15
17
  type Handler = (req: IncomingMessage, res: ServerResponse) => Promise<void>;
16
18
  export interface StatusBody {
17
19
  ok: true;
@@ -33,4 +35,6 @@ export declare function previewRoute(helper: HelperLike, settings: () => Setting
33
35
  export declare function screenshotsRoute(cache: ScreenshotCache): Handler;
34
36
  /** Delete orphaned screenshots now. */
35
37
  export declare function screenshotsCleanRoute(cache: ScreenshotCache): Handler;
38
+ /** App skills for the settings page: GET lists them; POST { op: 'save' | 'delete' | 'reset', ... } changes one. */
39
+ export declare function skillsRoute(skills: SkillStore): Handler;
36
40
  export {};
@@ -0,0 +1,59 @@
1
+ import { type WindowLike } from './access.js';
2
+ /** Notes longer than this must be condensed before more is added. */
3
+ export declare const SKILL_MAX_CHARS = 4000;
4
+ export interface Skill {
5
+ id: string;
6
+ app: string;
7
+ /** Names / exe names this skill applies to. */
8
+ match: string[];
9
+ summary: string;
10
+ content: string;
11
+ source: 'builtin' | 'user';
12
+ /** A user file replaces a built-in skill of the same id. */
13
+ overrides: boolean;
14
+ updatedAt: number;
15
+ }
16
+ export interface SkillInput {
17
+ app: string;
18
+ match?: string[];
19
+ summary?: string;
20
+ content: string;
21
+ }
22
+ interface Parsed {
23
+ app: string;
24
+ match: string[];
25
+ summary: string;
26
+ content: string;
27
+ disabled: boolean;
28
+ }
29
+ export declare function skillId(app: string): string;
30
+ export declare function parseSkill(text: string, fallbackApp: string): Parsed;
31
+ export declare function formatSkill(skill: {
32
+ app: string;
33
+ match: string[];
34
+ summary: string;
35
+ content: string;
36
+ }, disabled?: boolean): string;
37
+ export declare class SkillStore {
38
+ private readonly builtinDir;
39
+ readonly userDir: string;
40
+ constructor(builtinDir: string, userDir?: string);
41
+ private load;
42
+ /** Every active skill, user files first in precedence, sorted by app name. */
43
+ list(): Skill[];
44
+ get(id: string): Skill | undefined;
45
+ /** The skill for an app by name, or for a window by its executable. */
46
+ find(name: string, win?: WindowLike): Skill | undefined;
47
+ /** One line per skill for the system prompt. */
48
+ catalog(): string;
49
+ save(input: SkillInput, id?: string): Skill;
50
+ append(app: string, text: string, extra?: {
51
+ match?: string[];
52
+ summary?: string;
53
+ }): Skill;
54
+ /** Delete a user skill; a built-in one is hidden by a disabled override. */
55
+ remove(id: string): void;
56
+ /** Drop the user's override so the built-in skill applies again. */
57
+ reset(id: string): void;
58
+ }
59
+ export {};
@@ -1,5 +1,6 @@
1
1
  import type { ImageAttachmentRef } from '@deepseek-ai/dsh-attachment';
2
2
  import { defineTool } from '@deepseek-ai/dsh-tools';
3
+ import { type SkillStore } from './skills.js';
3
4
  import { Computer, type CallContext, type Shot } from './computer.js';
4
5
  type ToolDefinition = ReturnType<typeof defineTool>;
5
6
  export interface ToolHost {
@@ -8,6 +9,8 @@ export interface ToolHost {
8
9
  saveImage(shot: Shot, name: string): Promise<ImageAttachmentRef>;
9
10
  /** Build the per-call context (session, agent, vision support). */
10
11
  context(exec: unknown): Promise<CallContext>;
12
+ /** Per-app notes the agent keeps (optional: tests run without). */
13
+ skills?: SkillStore;
11
14
  }
12
15
  export declare function createTools(host: ToolHost): ToolDefinition[];
13
16
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copylee/dsh-computer-use",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "DeepSeek Harness Computer Use 插件(Windows):让 AI 看屏幕、点鼠标、敲键盘操控电脑;控制时屏幕泛起橙色光晕并显示“DeepSeek Harness 正在操控你的电脑”,按 Esc 暂停 / 继续。",
5
5
  "type": "module",
6
6
  "author": "copylee",
@@ -32,6 +32,7 @@
32
32
  "helper/CuHelper.cs",
33
33
  "helper/deepseek-white.png",
34
34
  "helper/deepseek-black.png",
35
+ "helper/skills/*.md",
35
36
  "cordis.patch.yml",
36
37
  "README.md",
37
38
  "LICENSE"