@yolk_vat-y/dsh-project-memory 0.6.3 → 0.6.4
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 +140 -8
- package/README.md +26 -23
- package/README.zh-CN.md +24 -21
- package/client/client.js +272 -138
- package/client/client.js.map +1 -1
- package/package.json +3 -2
- package/scripts/bench-synthetic.mjs +22 -11
- package/src/audit.js +36 -32
- package/src/auto-inject.js +44 -23
- package/src/client/MemoryView.tsx +72 -4
- package/src/client/ShowTaskPanelNode.tsx +8 -5
- package/src/client/TaskCommandNode.tsx +22 -17
- package/src/client/TaskComponents.tsx +18 -3
- package/src/client/TaskPanel.tsx +50 -85
- package/src/client/client.ts +26 -6
- package/src/client/commands.ts +67 -0
- package/src/client/task-ui-store.ts +15 -2
- package/src/commands/task-actions.js +56 -2
- package/src/index.js +12 -0
- package/src/insight-store.js +200 -78
- package/src/lazy.js +3 -1
- package/src/ops.js +1 -1
- package/src/readiness.js +1 -1
- package/src/recall.js +76 -30
- package/src/setup/taskbridge.js +34 -3
- package/src/store.js +315 -44
- package/src/tools/forget.js +11 -8
- package/src/tools/index-doc.js +3 -5
- package/src/tools/index-repo.js +10 -11
- package/src/tools/lesson-tools.js +25 -35
- package/src/tools/query-memory.js +81 -28
- package/src/tools/remember.js +14 -11
- package/src/tools/stats.js +26 -3
- package/src/tools/task-tools.js +11 -12
- package/src/tools/watch-repo.js +3 -5
- package/src/types.js +9 -4
- package/src/util/fs.js +128 -1
- package/src/util/search.js +6 -27
- package/src/vector-index.js +175 -22
- package/src/watch.js +2 -2
package/client/client.js
CHANGED
|
@@ -379,6 +379,75 @@ window.__ModuleLoader__.load({
|
|
|
379
379
|
} catch {}
|
|
380
380
|
}
|
|
381
381
|
//#endregion
|
|
382
|
+
//#region src/client/commands.ts
|
|
383
|
+
/**
|
|
384
|
+
* 客户端命令调用层:所有 `remote.commands.execute` 只走这里。
|
|
385
|
+
*
|
|
386
|
+
* 三件事必须集中在一处,否则每个调用点都会各漏一项:
|
|
387
|
+
* - 超时/取消(宿主 RPC 不返回时不能把面板永久锁死);
|
|
388
|
+
* - 信封解析(宿主 `{ok:false,error}` 与 `{ok:true,value}` 是两种形状);
|
|
389
|
+
* - 错误归一(调用点只关心 ok/text/error,不重复猜)。
|
|
390
|
+
*/
|
|
391
|
+
function errorText(value) {
|
|
392
|
+
if (typeof value === "string") return value;
|
|
393
|
+
if (value && typeof value === "object") {
|
|
394
|
+
const record = value;
|
|
395
|
+
if (typeof record.message === "string" && record.message) return record.message;
|
|
396
|
+
if (typeof record.code === "string" && record.code) return record.code;
|
|
397
|
+
}
|
|
398
|
+
return "";
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* 执行一条 `/tasks` 命令。
|
|
402
|
+
* @param ctx client 上下文(服务一律软探测)
|
|
403
|
+
* @param sessionId 当前会话;为空表示没有可用数据通道
|
|
404
|
+
* @param line 完整命令行(以 `/tasks` 开头)
|
|
405
|
+
* @param timeoutMs 超时;到点 abort,调用方拿到可重试的错误态
|
|
406
|
+
*/
|
|
407
|
+
async function invokeCommand(ctx, sessionId, line, timeoutMs = 15e3) {
|
|
408
|
+
const commands = service(ctx, "remote.commands");
|
|
409
|
+
if (!sessionId || !commands || typeof commands.execute !== "function") return {
|
|
410
|
+
ok: false,
|
|
411
|
+
text: "",
|
|
412
|
+
error: "no-channel"
|
|
413
|
+
};
|
|
414
|
+
const controller = typeof AbortController === "function" ? new AbortController() : null;
|
|
415
|
+
const timer = controller ? setTimeout(() => controller.abort(), timeoutMs) : null;
|
|
416
|
+
try {
|
|
417
|
+
const response = await commands.execute(sessionId, line, [], controller?.signal);
|
|
418
|
+
const envelope = response && typeof response === "object" ? response : null;
|
|
419
|
+
if (envelope && envelope.ok === false) return {
|
|
420
|
+
ok: false,
|
|
421
|
+
text: "",
|
|
422
|
+
error: errorText(envelope.error) || "command rejected"
|
|
423
|
+
};
|
|
424
|
+
const execution = envelope && "value" in envelope ? envelope.value : envelope;
|
|
425
|
+
if (execution === void 0 || execution === null) return {
|
|
426
|
+
ok: false,
|
|
427
|
+
text: "",
|
|
428
|
+
error: "unknown or malformed command"
|
|
429
|
+
};
|
|
430
|
+
const result = execution.result ?? execution;
|
|
431
|
+
if (result?.kind === "error") return {
|
|
432
|
+
ok: false,
|
|
433
|
+
text: "",
|
|
434
|
+
error: String(result.text ?? "command error")
|
|
435
|
+
};
|
|
436
|
+
return {
|
|
437
|
+
ok: true,
|
|
438
|
+
text: typeof result?.text === "string" ? result.text : ""
|
|
439
|
+
};
|
|
440
|
+
} catch (err) {
|
|
441
|
+
return {
|
|
442
|
+
ok: false,
|
|
443
|
+
text: "",
|
|
444
|
+
error: controller?.signal.aborted === true ? "command timed out" : String(err?.message ?? err)
|
|
445
|
+
};
|
|
446
|
+
} finally {
|
|
447
|
+
if (timer !== null) clearTimeout(timer);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
//#endregion
|
|
382
451
|
//#region src/client/task-scope.js
|
|
383
452
|
/**
|
|
384
453
|
* 跨标签页任务广播的**项目作用域**判定(纯函数,无 React / 无 BroadcastChannel 依赖)。
|
|
@@ -558,6 +627,18 @@ window.__ModuleLoader__.load({
|
|
|
558
627
|
y: 0
|
|
559
628
|
};
|
|
560
629
|
}
|
|
630
|
+
/** 位置必须留在视口内:换小屏/拔掉外接屏后,持久化的坐标可能已经看不见。 */
|
|
631
|
+
function clampPosition(value) {
|
|
632
|
+
if (typeof window === "undefined") return defaultPosition();
|
|
633
|
+
const pos = value;
|
|
634
|
+
const x = Number(pos?.x);
|
|
635
|
+
const y = Number(pos?.y);
|
|
636
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) return defaultPosition();
|
|
637
|
+
return {
|
|
638
|
+
x: Math.max(8, Math.min(x, window.innerWidth - 80)),
|
|
639
|
+
y: Math.max(8, Math.min(y, window.innerHeight - 40))
|
|
640
|
+
};
|
|
641
|
+
}
|
|
561
642
|
/**
|
|
562
643
|
* 启动时的初始状态:
|
|
563
644
|
* - closed 恒为 true(不读取 localStorage 的 closed),刷新后面板隐藏;
|
|
@@ -570,7 +651,7 @@ window.__ModuleLoader__.load({
|
|
|
570
651
|
const parsed = JSON.parse(saved);
|
|
571
652
|
return {
|
|
572
653
|
expandedTaskIds: Array.isArray(parsed.expandedTaskIds) ? parsed.expandedTaskIds : [],
|
|
573
|
-
panelPosition: parsed.panelPosition
|
|
654
|
+
panelPosition: clampPosition(parsed.panelPosition),
|
|
574
655
|
minimized: parsed.minimized !== false,
|
|
575
656
|
closed: true,
|
|
576
657
|
theme: typeof parsed.theme === "string" ? parsed.theme : "native",
|
|
@@ -630,7 +711,7 @@ window.__ModuleLoader__.load({
|
|
|
630
711
|
setPanelPosition(pos) {
|
|
631
712
|
setUIState({
|
|
632
713
|
...uiState,
|
|
633
|
-
panelPosition: pos
|
|
714
|
+
panelPosition: clampPosition(pos)
|
|
634
715
|
});
|
|
635
716
|
},
|
|
636
717
|
open() {
|
|
@@ -875,12 +956,17 @@ window.__ModuleLoader__.load({
|
|
|
875
956
|
//#region \0dsh-css:src/client/TaskPanel.module.css.mjs
|
|
876
957
|
const css$1 = ".vZSZnG_panel{pointer-events:auto;background:var(--dsw-alias-bg-layer-2,var(--dsw-alias-bg-base,#fff));border:1px solid var(--dsw-alias-border-l2,#7f7f7f4d);border-radius:14px;flex-direction:column;width:380px;max-width:calc(100vw - 24px);max-height:min(70vh,640px);font-family:inherit;animation:.18s ease-out vZSZnG_panelIn;display:flex;position:fixed;overflow:hidden;box-shadow:0 12px 32px #00000029,0 2px 8px #00000014}@keyframes vZSZnG_panelIn{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}.vZSZnG_dragHandle{cursor:grab;z-index:1;justify-content:center;align-items:center;height:12px;display:flex;position:absolute;top:0;left:0;right:0}.vZSZnG_dragHandle:active{cursor:grabbing}.vZSZnG_handleGrip{background:var(--dsw-alias-separator-primary,#7f7f7f59);opacity:.8;border-radius:2px;width:32px;height:3px}.vZSZnG_header{border-bottom:1px solid var(--dsw-alias-border-l1,#7f7f7f2e);-webkit-user-select:none;user-select:none;justify-content:space-between;align-items:center;gap:8px;padding:10px 10px 8px 14px;display:flex}.vZSZnG_headerLeft{align-items:center;gap:6px;min-width:0;display:flex}.vZSZnG_headerIcon{color:var(--dsw-alias-label-secondary);flex:none}.vZSZnG_headerTitle{color:var(--dsw-alias-label-primary);white-space:nowrap;margin:0;font-size:13px;font-weight:600;line-height:20px}.vZSZnG_headerRight{align-items:center;gap:2px;margin-left:auto;display:flex}.vZSZnG_hintsOff{opacity:.45}.vZSZnG_hintsOff:hover{opacity:.75}.vZSZnG_counts{color:var(--dsw-alias-label-tertiary);white-space:nowrap;margin-right:4px;font-size:11px;line-height:16px}.vZSZnG_boundBadge{color:var(--dsw-alias-label-primary-foreground,#fff);background:var(--dsw-alias-button-primary-fill,#3a6ef5);white-space:nowrap;border-radius:7px;flex:none;padding:0 6px;font-size:10px;line-height:14px}.vZSZnG_notice{color:var(--dsw-alias-state-warn-label,#b7791f);background:var(--dsw-alias-interactive-bg-hover,#7f7f7f1a);word-break:break-all;border-radius:8px;margin:8px 12px 0;padding:6px 10px;font-size:12px;line-height:18px}.vZSZnG_taskList{scrollbar-width:thin;scrollbar-color:var(--dsw-alias-scrollbar-bg-l2,transparent) transparent;flex-direction:column;gap:6px;padding:8px;display:flex;overflow-y:auto}.vZSZnG_emptyState{text-align:center;color:var(--dsw-alias-label-secondary);padding:36px 24px 30px}.vZSZnG_emptyTitle{color:var(--dsw-alias-label-primary);margin:0 0 6px;font-size:13px;font-weight:600}.vZSZnG_emptyDesc{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:20px}.vZSZnG_syncHint{color:var(--dsw-alias-label-dimmed);justify-content:center;align-items:center;gap:6px;margin:10px 0 0;font-size:11px;display:flex}.vZSZnG_card{border:1px solid var(--dsw-alias-border-l1,#7f7f7f29);background:var(--dsw-alias-bg-base,transparent);content-visibility:auto;contain-intrinsic-size:auto 140px;border-radius:10px;transition:border-color .15s;overflow:hidden}.vZSZnG_cardBound{border-color:var(--dsw-alias-border-l3,#7f7f7f59);box-shadow:inset 0 0 0 .5px var(--dsw-alias-border-l3,transparent)}.vZSZnG_cardHead{cursor:pointer;text-align:left;background:0 0;border:none;justify-content:space-between;align-items:center;gap:8px;width:100%;padding:8px 10px 7px;display:flex}.vZSZnG_cardHead:hover{background:var(--dsw-alias-interactive-bg-hover,#7f7f7f14)}.vZSZnG_cardTitleRow{align-items:center;gap:6px;min-width:0;display:flex}.vZSZnG_cardTitle{color:var(--dsw-alias-label-primary);white-space:nowrap;text-overflow:ellipsis;font-size:13px;font-weight:500;line-height:20px;overflow:hidden}.vZSZnG_cardMeta{color:var(--dsw-alias-label-tertiary);flex:none;align-items:center;gap:8px;display:flex}.vZSZnG_progressText{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-secondary);font-size:11px;line-height:16px}.vZSZnG_updated{color:var(--dsw-alias-label-dimmed);font-size:10px;line-height:14px}.vZSZnG_chevron{color:var(--dsw-alias-label-tertiary);display:inline-flex}.vZSZnG_track{background:var(--dsw-alias-interactive-bg-hover,#7f7f7f1f);border-radius:1px;height:2px;margin:0 10px 6px;overflow:hidden}.vZSZnG_trackFill{background:var(--dsw-alias-label-primary-bluish,var(--dsw-alias-button-primary-fill,#3a6ef5));border-radius:1px;height:100%;transition:width .2s}.vZSZnG_cardBody{border-top:1px solid var(--dsw-alias-border-l1,#7f7f7f24);overscroll-behavior:contain;max-height:300px;padding:8px 10px 10px;overflow-y:auto}.vZSZnG_section{margin-bottom:8px}.vZSZnG_section:last-child{margin-bottom:0}.vZSZnG_sectionLabel{color:var(--dsw-alias-label-secondary);align-items:center;gap:6px;margin-bottom:4px;font-size:11px;line-height:16px;display:flex}.vZSZnG_sectionCount{background:var(--dsw-alias-interactive-bg-hover,#7f7f7f1a);color:var(--dsw-alias-label-tertiary);border-radius:6px;padding:0 5px;font-size:10px;line-height:14px}.vZSZnG_stepsList{flex-direction:column;gap:1px;margin:0;padding:0;list-style:none;display:flex}.vZSZnG_stepRow{align-items:flex-start;gap:7px;padding:3px 2px;display:flex}.vZSZnG_stepRow>svg{flex:none;margin-top:2px}.vZSZnG_stepDone{color:var(--dsw-alias-label-dimmed)}.vZSZnG_stepRun{color:var(--dsw-alias-label-primary-bluish,#3a6ef5)}.vZSZnG_stepPending{background:var(--dsw-alias-border-l3,#7f7f7f80);border-radius:50%;flex:none;width:8px;height:8px;margin:5px 3px}.vZSZnG_stepContent{color:var(--dsw-alias-label-secondary);word-break:break-word;white-space:pre-wrap;font-size:12px;line-height:20px}.vZSZnG_stepContentDone{color:var(--dsw-alias-label-dimmed);text-decoration:line-through}.vZSZnG_stepContentRun{color:var(--dsw-alias-label-primary)}.vZSZnG_muted{color:var(--dsw-alias-label-dimmed);font-size:11px;line-height:18px}.vZSZnG_filesList{flex-direction:column;margin:0;padding:0;list-style:none;display:flex}.vZSZnG_fileRow{cursor:pointer;text-align:left;background:0 0;border:none;border-radius:6px;align-items:center;gap:6px;width:100%;padding:3px 4px;display:flex}.vZSZnG_fileRow:hover{background:var(--dsw-alias-interactive-bg-hover,#7f7f7f14)}.vZSZnG_fileDot{background:var(--dsw-alias-border-l3,#7f7f7f80);border-radius:50%;flex:none;width:5px;height:5px}.vZSZnG_filePath{color:var(--dsw-alias-label-secondary);white-space:nowrap;text-overflow:ellipsis;text-align:left;direction:rtl;font-family:ui-monospace,SF Mono,Menlo,Consolas,monospace;font-size:11px;line-height:18px;overflow:hidden}.vZSZnG_fileLine{color:var(--dsw-alias-label-dimmed);flex:none;font-size:10px;line-height:18px}.vZSZnG_cardFooter{gap:6px;margin-top:8px;display:flex}@media (prefers-reduced-motion:reduce){.vZSZnG_panel{animation:none}.vZSZnG_trackFill,.vZSZnG_card{transition:none}}.vZSZnG_miniBar{border:1px solid var(--dsw-alias-border-l3,#7f7f7f4d);background:var(--dsw-alias-bg-layer-2,var(--dsw-alias-bg-base,#fff));max-width:min(46vw,340px);height:34px;color:var(--dsw-alias-label-primary);cursor:grab;-webkit-user-select:none;user-select:none;pointer-events:auto;border-radius:999px;align-items:center;gap:7px;padding:0 12px;font-size:12px;line-height:18px;transition:background .15s,border-color .15s;display:inline-flex;position:fixed;box-shadow:0 6px 20px #00000024,0 1px 4px #00000014}.vZSZnG_miniBar:active{cursor:grabbing}.vZSZnG_miniBar:hover{background:var(--dsw-alias-interactive-bg-hover,#7f7f7f14)}.vZSZnG_miniIcon{color:var(--dsw-alias-label-secondary);flex:none}.vZSZnG_miniText{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.vZSZnG_miniChevron{color:var(--dsw-alias-label-tertiary);flex:none}.vZSZnG_taskList{flex:auto;min-height:0}.vZSZnG_card{flex-direction:column;display:flex}.vZSZnG_boundaryFallback{border:1px solid var(--dsw-alias-border-l3,#7f7f7f4d);background:var(--dsw-alias-bg-layer-2,#fff);color:var(--dsw-alias-label-secondary);cursor:pointer;pointer-events:auto;border-radius:999px;padding:4px 10px;font-size:12px;line-height:18px;position:fixed;top:64px;right:16px}.vZSZnG_stepToggle{cursor:pointer;background:0 0;border:none;border-radius:4px;flex:none;align-items:center;margin-top:2px;padding:0;display:inline-flex}.vZSZnG_stepToggle:hover{background:var(--dsw-alias-interactive-bg-hover,#7f7f7f1f)}.vZSZnG_stepToggle:disabled{cursor:default;opacity:.5}.vZSZnG_stepEditable{cursor:text;border-radius:3px}.vZSZnG_stepEditable:hover{outline:1px dashed var(--dsw-alias-border-l3,#7f7f7f66);outline-offset:1px}.vZSZnG_stepInput{box-sizing:border-box;width:auto;min-width:0;font:inherit;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-base,transparent);border:1px solid var(--dsw-alias-border-l3,#7f7f7f73);border-radius:5px;flex:auto;padding:0 5px;font-size:12px;line-height:20px}.vZSZnG_editorArea{box-sizing:border-box;min-width:0;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-base,transparent);border:1px solid var(--dsw-alias-border-l3,#7f7f7f73);resize:none;vertical-align:middle;cursor:text;white-space:pre-wrap;word-break:break-word;border-radius:5px;flex:1;margin:0;padding:2px 5px;font-family:inherit;font-size:12px;line-height:20px;overflow:hidden}.vZSZnG_editorArea:focus{border-color:var(--dsw-alias-border-l3,#7f7f7f99);outline:none}.vZSZnG_stepDragging{opacity:.3;background:var(--dsw-alias-interactive-bg-hover,#7f7f7f14)}.vZSZnG_cardTitleEditable{cursor:text;border-radius:3px}.vZSZnG_cardTitleEditable:hover{outline:1px dashed var(--dsw-alias-border-l3,#7f7f7f66);outline-offset:1px}.vZSZnG_panel[data-theme=glass],.vZSZnG_miniBar[data-theme=glass]{background:color-mix(in srgb, var(--dsw-alias-bg-layer-2,#fff) 90%, transparent);-webkit-backdrop-filter:blur(18px)saturate(1.2);border:1px solid color-mix(in srgb, var(--dsw-alias-border-l2,#7f7f7f4d) 80%, transparent)}.vZSZnG_panel[data-theme=glass] .vZSZnG_card{background:color-mix(in srgb, var(--dsw-alias-bg-base,transparent) 84%, transparent);border-color:color-mix(in srgb, var(--dsw-alias-border-l1,#7f7f7f29) 60%, transparent)}.vZSZnG_panel[data-theme=glass] .vZSZnG_cardBody{border-top-color:color-mix(in srgb, var(--dsw-alias-border-l1,#7f7f7f24) 60%, transparent)}@media (prefers-reduced-transparency:reduce){.vZSZnG_panel[data-theme=glass],.vZSZnG_miniBar[data-theme=glass]{background:var(--dsw-alias-bg-layer-2,#fff);-webkit-backdrop-filter:none;backdrop-filter:none}.vZSZnG_panel[data-theme=glass] .vZSZnG_card{background:var(--dsw-alias-bg-base,transparent)}}@supports not ((-webkit-backdrop-filter:blur(1px)) or (backdrop-filter:blur(1px))){.vZSZnG_panel[data-theme=glass],.vZSZnG_miniBar[data-theme=glass]{background:var(--dsw-alias-bg-layer-2,#fff)}}.vZSZnG_panel[data-theme=brutal]{box-shadow:none;border-width:1px;border-radius:6px}.vZSZnG_panel[data-theme=brutal] .vZSZnG_card{border:1px solid var(--dsw-alias-border-l3,#7f7f7f6b);background:var(--dsw-alias-bg-base,transparent);box-shadow:none;border-radius:3px}.vZSZnG_panel[data-theme=brutal] .vZSZnG_cardHead{padding:7px 10px 6px}.vZSZnG_panel[data-theme=brutal] .vZSZnG_cardTitle{letter-spacing:.01em;font-weight:650}.vZSZnG_panel[data-theme=brutal] .vZSZnG_headerTitle{letter-spacing:.03em}.vZSZnG_panel[data-theme=brutal] .vZSZnG_boundBadge{border-radius:2px}.vZSZnG_panel[data-theme=brutal] .vZSZnG_track{border-radius:0;height:3px}.vZSZnG_panel[data-theme=brutal] .vZSZnG_trackFill{border-radius:0}.vZSZnG_panel[data-theme=brutal] .vZSZnG_cardBody{border-top:1px solid var(--dsw-alias-border-l2,#7f7f7f3d)}.vZSZnG_panel[data-theme=mono] .vZSZnG_headerTitle,.vZSZnG_panel[data-theme=mono] .vZSZnG_counts,.vZSZnG_panel[data-theme=mono] .vZSZnG_cardTitle,.vZSZnG_panel[data-theme=mono] .vZSZnG_progressText,.vZSZnG_panel[data-theme=mono] .vZSZnG_stepContent,.vZSZnG_panel[data-theme=mono] .vZSZnG_filePath{font-family:ui-monospace,SF Mono,Menlo,Consolas,Liberation Mono,monospace}.vZSZnG_panel[data-theme=mono] .vZSZnG_cardTitle{font-size:12px}.vZSZnG_panel[data-theme=mono] .vZSZnG_stepContent{font-size:11.5px}.vZSZnG_panel[data-theme=mono] .vZSZnG_card{border-radius:5px}.vZSZnG_panel[data-theme=mono] .vZSZnG_trackFill{border-radius:0}.vZSZnG_panel[data-theme=mono] .vZSZnG_stepPending{border-radius:1px}.vZSZnG_panel[data-theme=mono] .vZSZnG_updated{letter-spacing:.02em}.vZSZnG_headerIconBtn{color:inherit;cursor:pointer;background:0 0;border:none;border-radius:0;flex:none;justify-content:center;align-items:center;margin:0;padding:0;display:inline-flex}.vZSZnG_headerIcon{color:var(--dsw-alias-label-secondary);flex:none;display:block}.vZSZnG_headerLeft{min-width:0}.vZSZnG_headerTitle{text-overflow:ellipsis;flex:0 auto;min-width:0;overflow:hidden}.vZSZnG_headerRight{min-width:0}.vZSZnG_counts{text-overflow:ellipsis;flex:none;max-width:45%;margin-left:auto;overflow:hidden}.vZSZnG_dragGhost{pointer-events:none;z-index:9999;transition:left 50ms,top 50ms;position:fixed;transform:translate(-50%,-50%)}.vZSZnG_dragGhostCard{background:var(--dsw-alias-bg-layer-2,var(--dsw-alias-bg-base,#fff));border:1px solid var(--dsw-alias-border-l3,#7f7f7f59);color:var(--dsw-alias-label-primary);white-space:nowrap;border-radius:8px;align-items:center;gap:8px;max-width:280px;padding:8px 12px;font-size:12px;line-height:20px;display:inline-flex;transform:scale(.9);box-shadow:0 8px 24px #0000002e,0 2px 8px #0000001a}.vZSZnG_dragGhostContent{text-overflow:ellipsis;word-break:break-word;flex:1;min-width:0;overflow:hidden}.vZSZnG_dragGhostClose{width:20px;height:20px;color:var(--dsw-alias-label-tertiary);cursor:pointer;opacity:.6;background:0 0;border:none;border-radius:4px;flex:none;justify-content:center;align-items:center;margin-left:8px;font-size:16px;line-height:1;transition:opacity .15s,background .15s,color .15s;display:inline-flex}.vZSZnG_dragGhostClose:hover{opacity:1;color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-interactive-bg-hover,#7f7f7f1f)}.vZSZnG_dropTargetBefore{position:relative}.vZSZnG_dropTargetBefore:before{content:\"\";background:var(--dsw-alias-button-primary-fill,#3a6ef5);height:2px;box-shadow:0 0 4px var(--dsw-alias-button-primary-fill,#3a6ef5);border-radius:1px;animation:.8s ease-in-out infinite vZSZnG_dropPulse;position:absolute;top:-1px;left:0;right:0}.vZSZnG_dropTargetAfter{position:relative}.vZSZnG_dropTargetAfter:after{content:\"\";background:var(--dsw-alias-button-primary-fill,#3a6ef5);height:2px;box-shadow:0 0 4px var(--dsw-alias-button-primary-fill,#3a6ef5);border-radius:1px;animation:.8s ease-in-out infinite vZSZnG_dropPulse;position:absolute;bottom:-1px;left:0;right:0}@keyframes vZSZnG_dropPulse{0%,to{opacity:.6}50%{opacity:1}}.vZSZnG_memoryPane{flex-direction:column;gap:6px;max-height:480px;padding:8px 10px 10px;display:flex;overflow:auto}.vZSZnG_memToolbar{justify-content:space-between;align-items:center;gap:8px;display:flex}.vZSZnG_memCount{opacity:.75;font-size:12px;font-weight:600}.vZSZnG_memList{flex-direction:column;gap:6px;display:flex}.vZSZnG_memSentinel{flex:none;height:1px}.vZSZnG_memFooter{flex-direction:column;align-items:center;gap:4px;padding:6px 0 2px;font-size:12px;display:flex}.vZSZnG_memRow{border:1px solid var(--dsw-border-weak,#80808040);background:color-mix(in srgb, var(--dsw-bg-secondary,#f5f5f5) 45%, transparent);content-visibility:auto;contain-intrinsic-size:auto 76px;border-radius:6px;flex-direction:column;gap:4px;padding:6px 8px;display:flex}.vZSZnG_memRowArchived{opacity:.55}.vZSZnG_memRowMain{flex-direction:column;gap:2px;display:flex}.vZSZnG_memTitle{word-break:break-word;align-items:flex-start;gap:6px;font-size:13px;line-height:1.35;display:flex}.vZSZnG_kindBadge{background:var(--dsw-accent-soft,#5078ff26);color:var(--dsw-accent,#4d6bfe);border-radius:4px;flex:none;padding:0 5px;font-size:11px;line-height:1.5}.vZSZnG_memMeta{flex-wrap:wrap;align-items:center;gap:4px;display:flex}.vZSZnG_badge{background:color-mix(in srgb, var(--dsw-fg,#222) 8%, transparent);border-radius:4px;padding:0 5px;font-size:11px;line-height:1.5}.vZSZnG_badgeDraft{color:#b26a00;background:#ffb40029}.vZSZnG_badgeArchived{opacity:.8}.vZSZnG_memBody{opacity:.8;word-break:break-word;font-size:12px}.vZSZnG_memActs{flex-wrap:wrap;gap:4px;display:flex}.vZSZnG_memToolbarActs{align-items:center;gap:6px;display:flex}.vZSZnG_memNew{border:1px solid var(--dsw-border-weak,#80808040);border-radius:6px;flex-direction:column;gap:6px;padding:8px;display:flex}.vZSZnG_memNewRow{align-items:center;gap:8px;display:flex}.vZSZnG_memLabel{opacity:.8;align-items:center;gap:6px;font-size:12px;display:inline-flex}.vZSZnG_memNew select,.vZSZnG_memNew textarea{box-sizing:border-box;width:100%}";
|
|
877
958
|
const tagId$1 = "@yolk_vat-y/dsh-project-memory/TaskPanel.module.css";
|
|
878
|
-
if (typeof document !== "undefined"
|
|
879
|
-
const
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
959
|
+
if (typeof document !== "undefined") {
|
|
960
|
+
const selector = "style[data-plugin-css=" + JSON.stringify(tagId$1) + "]";
|
|
961
|
+
const existing = document.querySelector(selector);
|
|
962
|
+
if (existing) existing.textContent = css$1;
|
|
963
|
+
else {
|
|
964
|
+
const tag = document.createElement("style");
|
|
965
|
+
tag.dataset.plugin = "@yolk_vat-y/dsh-project-memory";
|
|
966
|
+
tag.dataset.pluginCss = tagId$1;
|
|
967
|
+
tag.textContent = css$1;
|
|
968
|
+
document.head.appendChild(tag);
|
|
969
|
+
}
|
|
884
970
|
}
|
|
885
971
|
var TaskPanel_module_css_default = {
|
|
886
972
|
"badge": "vZSZnG_badge",
|
|
@@ -1093,7 +1179,14 @@ window.__ModuleLoader__.load({
|
|
|
1093
1179
|
},
|
|
1094
1180
|
"data-theme": theme === "native" ? void 0 : theme,
|
|
1095
1181
|
onMouseDown,
|
|
1182
|
+
onKeyDown: (e) => {
|
|
1183
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1184
|
+
e.preventDefault();
|
|
1185
|
+
open();
|
|
1186
|
+
}
|
|
1187
|
+
},
|
|
1096
1188
|
role: "button",
|
|
1189
|
+
tabIndex: 0,
|
|
1097
1190
|
title: showHints ? hint : void 0,
|
|
1098
1191
|
"aria-label": hint,
|
|
1099
1192
|
children: [
|
|
@@ -1154,9 +1247,17 @@ window.__ModuleLoader__.load({
|
|
|
1154
1247
|
"data-task-id": task.id,
|
|
1155
1248
|
className: `${TaskPanel_module_css_default.card}${isBound ? ` ${TaskPanel_module_css_default.cardBound}` : ""}`,
|
|
1156
1249
|
children: [
|
|
1157
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
1250
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1158
1251
|
className: TaskPanel_module_css_default.cardHead,
|
|
1252
|
+
role: "button",
|
|
1253
|
+
tabIndex: 0,
|
|
1159
1254
|
onClick: handleHeadClick,
|
|
1255
|
+
onKeyDown: (e) => {
|
|
1256
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1257
|
+
e.preventDefault();
|
|
1258
|
+
handleHeadClick(e);
|
|
1259
|
+
}
|
|
1260
|
+
},
|
|
1160
1261
|
onMouseDownCapture: () => {
|
|
1161
1262
|
if (titleEdit !== null) suppressHeadClick.current = true;
|
|
1162
1263
|
},
|
|
@@ -1567,6 +1668,42 @@ window.__ModuleLoader__.load({
|
|
|
1567
1668
|
* 列表是**增量加载**的:首屏只取 PAGE_SIZE 条,滚到底前 600px 预取下一页追加。
|
|
1568
1669
|
* 分页的决策逻辑在 ./paging.js(纯函数,可单测),本组件只把它接到渲染上。
|
|
1569
1670
|
*/
|
|
1671
|
+
/**
|
|
1672
|
+
* 切页缓存:任务/项目/全局三页在同一个面板里来回切时,30 秒内直接复用上一份列表,
|
|
1673
|
+
* 不再发 /tasks insight list。宿主每次命令都会在会话里留一个 command 节点,
|
|
1674
|
+
* 而"切回刚才那页"并不需要重新证明数据没变;动作之后的 reloadWindow 会更新缓存。
|
|
1675
|
+
*/
|
|
1676
|
+
const INSIGHT_CACHE_TTL_MS = 3e4;
|
|
1677
|
+
const INSIGHT_CACHE_MAX = 12;
|
|
1678
|
+
const insightCache = /* @__PURE__ */ new Map();
|
|
1679
|
+
function insightCacheKey(sessionId, scope, root, boundTaskId) {
|
|
1680
|
+
return `${sessionId || ""}|${root || ""}|${scope}|${boundTaskId || ""}`;
|
|
1681
|
+
}
|
|
1682
|
+
function readInsightCache(sessionId, scope, root, boundTaskId) {
|
|
1683
|
+
const key = insightCacheKey(sessionId, scope, root, boundTaskId);
|
|
1684
|
+
const hit = insightCache.get(key);
|
|
1685
|
+
if (!hit) return null;
|
|
1686
|
+
if (Date.now() - hit.at > INSIGHT_CACHE_TTL_MS) {
|
|
1687
|
+
insightCache.delete(key);
|
|
1688
|
+
return null;
|
|
1689
|
+
}
|
|
1690
|
+
return hit;
|
|
1691
|
+
}
|
|
1692
|
+
function writeInsightCache(sessionId, scope, root, boundTaskId, rows, total, nextOffset) {
|
|
1693
|
+
const key = insightCacheKey(sessionId, scope, root, boundTaskId);
|
|
1694
|
+
insightCache.delete(key);
|
|
1695
|
+
insightCache.set(key, {
|
|
1696
|
+
rows,
|
|
1697
|
+
total,
|
|
1698
|
+
nextOffset,
|
|
1699
|
+
at: Date.now()
|
|
1700
|
+
});
|
|
1701
|
+
while (insightCache.size > INSIGHT_CACHE_MAX) {
|
|
1702
|
+
const oldest = insightCache.keys().next().value;
|
|
1703
|
+
if (oldest === void 0) break;
|
|
1704
|
+
insightCache.delete(oldest);
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1570
1707
|
function parseInsightPayloadText(text) {
|
|
1571
1708
|
if (!text) return null;
|
|
1572
1709
|
let jsonBlock = null;
|
|
@@ -1601,7 +1738,7 @@ window.__ModuleLoader__.load({
|
|
|
1601
1738
|
experience: t("mem.kind.experience")
|
|
1602
1739
|
}[kind] ?? kind;
|
|
1603
1740
|
}
|
|
1604
|
-
function MemoryView({ ctx, sessionId, scope, boundTaskId, showHints, t }) {
|
|
1741
|
+
function MemoryView({ ctx, sessionId, scope, root, boundTaskId, showHints, t }) {
|
|
1605
1742
|
const [rows, setRows] = (0, react.useState)([]);
|
|
1606
1743
|
const [total, setTotal] = (0, react.useState)(0);
|
|
1607
1744
|
const [nextOffset, setNextOffset] = (0, react.useState)(null);
|
|
@@ -1688,7 +1825,11 @@ window.__ModuleLoader__.load({
|
|
|
1688
1825
|
setError("unparsable payload");
|
|
1689
1826
|
return;
|
|
1690
1827
|
}
|
|
1691
|
-
setRows((prev) =>
|
|
1828
|
+
setRows((prev) => {
|
|
1829
|
+
const next = append ? appendUnique(prev, parsed.items) : parsed.items;
|
|
1830
|
+
writeInsightCache(sessionId, requestedScope, root, boundTaskId, next, parsed.total, parsed.nextOffset);
|
|
1831
|
+
return next;
|
|
1832
|
+
});
|
|
1692
1833
|
setTotal(parsed.total);
|
|
1693
1834
|
setNextOffset(parsed.nextOffset);
|
|
1694
1835
|
} finally {
|
|
@@ -1699,7 +1840,12 @@ window.__ModuleLoader__.load({
|
|
|
1699
1840
|
setLoadingMore(false);
|
|
1700
1841
|
}
|
|
1701
1842
|
}
|
|
1702
|
-
}, [
|
|
1843
|
+
}, [
|
|
1844
|
+
runLine,
|
|
1845
|
+
sessionId,
|
|
1846
|
+
root,
|
|
1847
|
+
boundTaskId
|
|
1848
|
+
]);
|
|
1703
1849
|
const loadRef = (0, react.useRef)(load);
|
|
1704
1850
|
(0, react.useEffect)(() => {
|
|
1705
1851
|
loadRef.current = load;
|
|
@@ -1710,6 +1856,16 @@ window.__ModuleLoader__.load({
|
|
|
1710
1856
|
setNextOffset(null);
|
|
1711
1857
|
setError(null);
|
|
1712
1858
|
if (!sessionId) return;
|
|
1859
|
+
const cached = readInsightCache(sessionId, scope, root, boundTaskId);
|
|
1860
|
+
if (cached) {
|
|
1861
|
+
setRows(cached.rows);
|
|
1862
|
+
setTotal(cached.total);
|
|
1863
|
+
setNextOffset(cached.nextOffset);
|
|
1864
|
+
setLoading(false);
|
|
1865
|
+
setLoadingMore(false);
|
|
1866
|
+
setShowSpinner(false);
|
|
1867
|
+
return;
|
|
1868
|
+
}
|
|
1713
1869
|
loadRef.current(0, 30, false);
|
|
1714
1870
|
}, [scope, sessionId]);
|
|
1715
1871
|
(0, react.useEffect)(() => {
|
|
@@ -2029,7 +2185,7 @@ window.__ModuleLoader__.load({
|
|
|
2029
2185
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2030
2186
|
className: TaskPanel_module_css_default.memActs,
|
|
2031
2187
|
children: [
|
|
2032
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
2188
|
+
scope !== "task" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
2033
2189
|
variant: "outline",
|
|
2034
2190
|
size: "sm",
|
|
2035
2191
|
disabled: busy,
|
|
@@ -2255,6 +2411,7 @@ window.__ModuleLoader__.load({
|
|
|
2255
2411
|
const degraded = missingServices(ctx);
|
|
2256
2412
|
const sessionId = useSessionId(ctx);
|
|
2257
2413
|
const [syncing, setSyncing] = (0, react.useState)(false);
|
|
2414
|
+
const syncingRef = (0, react.useRef)(false);
|
|
2258
2415
|
const [syncedAt, setSyncedAt] = (0, react.useState)(0);
|
|
2259
2416
|
const [syncError, setSyncError] = (0, react.useState)(null);
|
|
2260
2417
|
const showHints = ui.showHints;
|
|
@@ -2283,26 +2440,23 @@ window.__ModuleLoader__.load({
|
|
|
2283
2440
|
return true;
|
|
2284
2441
|
};
|
|
2285
2442
|
const runLine = async (line) => {
|
|
2286
|
-
const
|
|
2287
|
-
if (!
|
|
2288
|
-
setSyncError(t("panel.no-channel"));
|
|
2443
|
+
const result = await invokeCommand(ctx, sessionId, line);
|
|
2444
|
+
if (!result.ok) {
|
|
2445
|
+
setSyncError(result.error === "no-channel" ? t("panel.no-channel") : result.error || t("panel.sync-failed"));
|
|
2289
2446
|
return false;
|
|
2290
2447
|
}
|
|
2291
|
-
|
|
2448
|
+
return applyPayload(result.text);
|
|
2449
|
+
};
|
|
2450
|
+
const withLock = async (fn) => {
|
|
2451
|
+
if (syncingRef.current) return;
|
|
2452
|
+
syncingRef.current = true;
|
|
2453
|
+
setSyncing(true);
|
|
2292
2454
|
try {
|
|
2293
|
-
|
|
2294
|
-
}
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
}
|
|
2298
|
-
const envelope = response;
|
|
2299
|
-
const execution = envelope && typeof envelope === "object" && "value" in envelope ? envelope.value : envelope;
|
|
2300
|
-
const result = execution?.result ?? execution;
|
|
2301
|
-
if (result?.kind === "error") {
|
|
2302
|
-
setSyncError(result.text ?? "command error");
|
|
2303
|
-
return false;
|
|
2455
|
+
await fn();
|
|
2456
|
+
} finally {
|
|
2457
|
+
syncingRef.current = false;
|
|
2458
|
+
setSyncing(false);
|
|
2304
2459
|
}
|
|
2305
|
-
return applyPayload(result?.text);
|
|
2306
2460
|
};
|
|
2307
2461
|
/**
|
|
2308
2462
|
* 只取数据,**不**顺手 switch。
|
|
@@ -2316,83 +2470,46 @@ window.__ModuleLoader__.load({
|
|
|
2316
2470
|
* 它们各自会推宿主清单(adoptStepsToSession),不需要巡检式补写。
|
|
2317
2471
|
*/
|
|
2318
2472
|
const refresh = async () => {
|
|
2319
|
-
|
|
2320
|
-
setSyncing(true);
|
|
2321
|
-
try {
|
|
2322
|
-
await runLine("/tasks");
|
|
2323
|
-
} finally {
|
|
2324
|
-
setSyncing(false);
|
|
2325
|
-
}
|
|
2473
|
+
await withLock(() => runLine("/tasks"));
|
|
2326
2474
|
};
|
|
2327
2475
|
const handleAction = async (verb, taskId) => {
|
|
2328
|
-
|
|
2329
|
-
setSyncing(true);
|
|
2330
|
-
try {
|
|
2331
|
-
await runLine(`/tasks ${verb} ${taskId}`);
|
|
2332
|
-
} finally {
|
|
2333
|
-
setSyncing(false);
|
|
2334
|
-
}
|
|
2476
|
+
await withLock(() => runLine(`/tasks ${verb} ${taskId}`));
|
|
2335
2477
|
};
|
|
2336
2478
|
const handleInsightTask = async (action, id) => {
|
|
2337
|
-
|
|
2338
|
-
setSyncing(true);
|
|
2339
|
-
try {
|
|
2479
|
+
await withLock(async () => {
|
|
2340
2480
|
await runLine(`/tasks insight ${action} task ${id}`);
|
|
2341
|
-
await
|
|
2342
|
-
}
|
|
2343
|
-
setSyncing(false);
|
|
2344
|
-
}
|
|
2345
|
-
};
|
|
2346
|
-
const pushSteps = (taskId, steps) => {
|
|
2347
|
-
runLine(`/tasks todos ${JSON.stringify(steps.map((s) => ({
|
|
2348
|
-
content: s.content,
|
|
2349
|
-
status: s.status
|
|
2350
|
-
})))}`);
|
|
2481
|
+
await runLine("/tasks");
|
|
2482
|
+
});
|
|
2351
2483
|
};
|
|
2352
2484
|
const cycleStatus = (taskId, index) => {
|
|
2353
2485
|
const task = data.tasks.find((tt) => tt.id === taskId);
|
|
2354
2486
|
if (!task) return;
|
|
2355
|
-
const
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
return {
|
|
2359
|
-
...s,
|
|
2360
|
-
status: STATUS_CYCLE[(cur + 1) % STATUS_CYCLE.length]
|
|
2361
|
-
};
|
|
2362
|
-
});
|
|
2363
|
-
pushSteps(taskId, next);
|
|
2487
|
+
const cur = STATUS_CYCLE.indexOf((task.steps || [])[index]?.status);
|
|
2488
|
+
const next = STATUS_CYCLE[(cur + 1) % STATUS_CYCLE.length];
|
|
2489
|
+
withLock(() => runLine(`/tasks step ${taskId} ${index} ${next}`));
|
|
2364
2490
|
};
|
|
2365
2491
|
const commitStepText = (taskId, index, value) => {
|
|
2366
2492
|
const task = data.tasks.find((tt) => tt.id === taskId);
|
|
2367
2493
|
const trimmed = value.trim();
|
|
2368
2494
|
if (!task) return;
|
|
2369
2495
|
if ((task.steps || [])[index]?.content === trimmed || !trimmed) return;
|
|
2370
|
-
|
|
2371
|
-
...s,
|
|
2372
|
-
content: trimmed
|
|
2373
|
-
} : s);
|
|
2374
|
-
pushSteps(taskId, next);
|
|
2496
|
+
withLock(() => runLine(`/tasks step-text ${taskId} ${index} ${JSON.stringify(trimmed)}`));
|
|
2375
2497
|
};
|
|
2376
2498
|
const reorderSteps = (taskId, fromIndex, toIndex) => {
|
|
2377
2499
|
if (fromIndex === toIndex) return;
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
const steps = [...task.steps || []];
|
|
2381
|
-
const [moved] = steps.splice(fromIndex, 1);
|
|
2382
|
-
const targetIndex = toIndex > fromIndex ? toIndex - 1 : toIndex;
|
|
2383
|
-
steps.splice(targetIndex, 0, moved);
|
|
2384
|
-
pushSteps(taskId, steps);
|
|
2500
|
+
if (!data.tasks.find((tt) => tt.id === taskId)) return;
|
|
2501
|
+
withLock(() => runLine(`/tasks step-move ${taskId} ${fromIndex} ${toIndex}`));
|
|
2385
2502
|
};
|
|
2386
2503
|
const commitTitle = (taskId, value) => {
|
|
2387
2504
|
const task = data.tasks.find((tt) => tt.id === taskId);
|
|
2388
2505
|
const trimmed = value.trim();
|
|
2389
2506
|
if (!task) return;
|
|
2390
2507
|
if (task.title === trimmed || !trimmed) return;
|
|
2391
|
-
runLine(`/tasks rename ${taskId} ${JSON.stringify(trimmed)}`);
|
|
2508
|
+
withLock(() => runLine(`/tasks rename ${taskId} ${JSON.stringify(trimmed)}`));
|
|
2392
2509
|
};
|
|
2393
2510
|
const expand = () => {
|
|
2394
2511
|
uiActions.open();
|
|
2395
|
-
if (Date.now() - Math.max(data.lastUpdate, syncedAt) >
|
|
2512
|
+
if (Date.now() - Math.max(data.lastUpdate, syncedAt) > 5e3) refresh();
|
|
2396
2513
|
};
|
|
2397
2514
|
const THEMES = [
|
|
2398
2515
|
"native",
|
|
@@ -2408,6 +2525,8 @@ window.__ModuleLoader__.load({
|
|
|
2408
2525
|
};
|
|
2409
2526
|
const panelRef = (0, react.useRef)(null);
|
|
2410
2527
|
const drag = (0, react.useRef)(null);
|
|
2528
|
+
const [dragPos, setDragPos] = (0, react.useState)(null);
|
|
2529
|
+
const dragPosRef = (0, react.useRef)(null);
|
|
2411
2530
|
const handleDragStart = (e) => {
|
|
2412
2531
|
if (e.target !== e.currentTarget) return;
|
|
2413
2532
|
const rect = panelRef.current?.getBoundingClientRect();
|
|
@@ -2422,7 +2541,11 @@ window.__ModuleLoader__.load({
|
|
|
2422
2541
|
panelRef.current?.offsetHeight;
|
|
2423
2542
|
const x = Math.max(8, Math.min(window.innerWidth - width - 8, ev.clientX - drag.current.dx));
|
|
2424
2543
|
const y = Math.max(8, Math.min(window.innerHeight - 64, ev.clientY - drag.current.dy));
|
|
2425
|
-
|
|
2544
|
+
dragPosRef.current = {
|
|
2545
|
+
x,
|
|
2546
|
+
y
|
|
2547
|
+
};
|
|
2548
|
+
setDragPos({
|
|
2426
2549
|
x,
|
|
2427
2550
|
y
|
|
2428
2551
|
});
|
|
@@ -2431,30 +2554,25 @@ window.__ModuleLoader__.load({
|
|
|
2431
2554
|
drag.current = null;
|
|
2432
2555
|
window.removeEventListener("mousemove", onMove);
|
|
2433
2556
|
window.removeEventListener("mouseup", onUp);
|
|
2557
|
+
if (dragPosRef.current) uiActions.setPanelPosition(dragPosRef.current);
|
|
2558
|
+
dragPosRef.current = null;
|
|
2559
|
+
setDragPos(null);
|
|
2434
2560
|
};
|
|
2435
2561
|
window.addEventListener("mousemove", onMove);
|
|
2436
2562
|
window.addEventListener("mouseup", onUp);
|
|
2437
2563
|
};
|
|
2564
|
+
const refreshRef = (0, react.useRef)(() => {});
|
|
2565
|
+
refreshRef.current = () => {
|
|
2566
|
+
refresh();
|
|
2567
|
+
};
|
|
2438
2568
|
(0, react.useEffect)(() => {
|
|
2439
|
-
if (!sessionId) return;
|
|
2440
|
-
if (
|
|
2441
|
-
|
|
2442
|
-
(0, react.useEffect)(() => {
|
|
2443
|
-
const ctxWithEvents = ctx;
|
|
2444
|
-
const handler = () => {
|
|
2445
|
-
uiActions.open();
|
|
2446
|
-
if (Date.now() - Math.max(data.lastUpdate, syncedAt) > 3e4) refresh();
|
|
2447
|
-
};
|
|
2448
|
-
ctxWithEvents?.events?.on?.("dsh:task-panel:show", handler);
|
|
2449
|
-
return () => {
|
|
2450
|
-
ctxWithEvents?.events?.off?.("dsh:task-panel:show", handler);
|
|
2451
|
-
};
|
|
2569
|
+
if (ui.closed || !sessionId || ui.view !== "task") return;
|
|
2570
|
+
if (Date.now() - Math.max(data.lastUpdate, syncedAt) < 5e3) return;
|
|
2571
|
+
refreshRef.current();
|
|
2452
2572
|
}, [
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
syncedAt,
|
|
2457
|
-
refresh
|
|
2573
|
+
ui.closed,
|
|
2574
|
+
ui.view,
|
|
2575
|
+
sessionId
|
|
2458
2576
|
]);
|
|
2459
2577
|
if (ui.closed) return null;
|
|
2460
2578
|
if (ui.minimized) {
|
|
@@ -2477,8 +2595,8 @@ window.__ModuleLoader__.load({
|
|
|
2477
2595
|
className: TaskPanel_module_css_default.panel,
|
|
2478
2596
|
ref: panelRef,
|
|
2479
2597
|
style: {
|
|
2480
|
-
left: ui.panelPosition.x,
|
|
2481
|
-
top: ui.panelPosition.y
|
|
2598
|
+
left: (dragPos ?? ui.panelPosition).x,
|
|
2599
|
+
top: (dragPos ?? ui.panelPosition).y
|
|
2482
2600
|
},
|
|
2483
2601
|
"data-theme": style === "native" ? void 0 : style,
|
|
2484
2602
|
children: [
|
|
@@ -2594,6 +2712,7 @@ window.__ModuleLoader__.load({
|
|
|
2594
2712
|
ctx,
|
|
2595
2713
|
sessionId,
|
|
2596
2714
|
scope: view,
|
|
2715
|
+
root: data.root ?? null,
|
|
2597
2716
|
boundTaskId: data.boundTaskId,
|
|
2598
2717
|
showHints,
|
|
2599
2718
|
t
|
|
@@ -2648,12 +2767,17 @@ window.__ModuleLoader__.load({
|
|
|
2648
2767
|
//#region \0dsh-css:src/client/TaskCommandNode.module.css.mjs
|
|
2649
2768
|
const css = ".TPe-xa_row{max-width:100%;color:var(--dsw-alias-label-tertiary);white-space:nowrap;text-overflow:ellipsis;align-items:center;gap:6px;padding:2px 0;font-size:12px;line-height:20px;display:inline-flex;overflow:hidden}.TPe-xa_row[data-variant=ok]{color:var(--dsw-alias-label-secondary)}.TPe-xa_row[data-variant=error]{color:var(--dsw-alias-state-warn-label,#b7791f)}.TPe-xa_row[data-variant=running]{color:var(--dsw-alias-label-dimmed)}.TPe-xa_icon{color:var(--dsw-alias-label-tertiary);flex:none}";
|
|
2650
2769
|
const tagId = "@yolk_vat-y/dsh-project-memory/TaskCommandNode.module.css";
|
|
2651
|
-
if (typeof document !== "undefined"
|
|
2652
|
-
const
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2770
|
+
if (typeof document !== "undefined") {
|
|
2771
|
+
const selector = "style[data-plugin-css=" + JSON.stringify(tagId) + "]";
|
|
2772
|
+
const existing = document.querySelector(selector);
|
|
2773
|
+
if (existing) existing.textContent = css;
|
|
2774
|
+
else {
|
|
2775
|
+
const tag = document.createElement("style");
|
|
2776
|
+
tag.dataset.plugin = "@yolk_vat-y/dsh-project-memory";
|
|
2777
|
+
tag.dataset.pluginCss = tagId;
|
|
2778
|
+
tag.textContent = css;
|
|
2779
|
+
document.head.appendChild(tag);
|
|
2780
|
+
}
|
|
2657
2781
|
}
|
|
2658
2782
|
var TaskCommandNode_module_css_default = {
|
|
2659
2783
|
"icon": "TPe-xa_icon",
|
|
@@ -2669,11 +2793,16 @@ window.__ModuleLoader__.load({
|
|
|
2669
2793
|
function TaskCommandNode({ node }) {
|
|
2670
2794
|
const name = node?.name ?? "task";
|
|
2671
2795
|
const outcome = node?.outcome ?? null;
|
|
2672
|
-
const
|
|
2673
|
-
const
|
|
2796
|
+
const tokens = (typeof node?.args === "string" ? node.args : "").trim().split(/\s+/).filter(Boolean);
|
|
2797
|
+
const verb = tokens[0] ?? "";
|
|
2798
|
+
const sub = tokens[1] ?? "";
|
|
2799
|
+
const isTasks = name === "tasks";
|
|
2800
|
+
const isInsight = name === "insight" || isTasks && verb === "insight";
|
|
2801
|
+
const insightVerb = name === "insight" ? verb : sub;
|
|
2802
|
+
const isList = isInsight ? name === "insight" ? !verb || verb === "list" : sub === "list" : isTasks && !verb;
|
|
2674
2803
|
const text = outcome?.text ?? "";
|
|
2675
|
-
const parsedTasks =
|
|
2676
|
-
const parsedInsights =
|
|
2804
|
+
const parsedTasks = isInsight ? null : parseTaskPayloadText(text);
|
|
2805
|
+
const parsedInsights = isInsight ? parseInsightPayloadText(text) : null;
|
|
2677
2806
|
const live = (0, react.useRef)(outcome === null);
|
|
2678
2807
|
(0, react.useEffect)(() => {
|
|
2679
2808
|
if (!parsedTasks || !live.current) return;
|
|
@@ -2707,29 +2836,15 @@ window.__ModuleLoader__.load({
|
|
|
2707
2836
|
]
|
|
2708
2837
|
});
|
|
2709
2838
|
}
|
|
2710
|
-
if (
|
|
2711
|
-
|
|
2712
|
-
const scope = parsedInsights.scope;
|
|
2713
|
-
const count = parsedInsights.count ?? parsedInsights.items.length;
|
|
2714
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2715
|
-
className: TaskCommandNode_module_css_default.row,
|
|
2716
|
-
"data-variant": "ok",
|
|
2717
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconFolderOpenOutline16, { className: TaskCommandNode_module_css_default.icon }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
2718
|
-
"记忆 ",
|
|
2719
|
-
scope,
|
|
2720
|
-
" · ",
|
|
2721
|
-
count,
|
|
2722
|
-
" 条 · 已同步到记忆视图"
|
|
2723
|
-
] })]
|
|
2724
|
-
});
|
|
2725
|
-
}
|
|
2839
|
+
if (isList && (isInsight ? parsedInsights : parsedTasks)) return null;
|
|
2840
|
+
if (isInsight) {
|
|
2726
2841
|
const note = String(text ?? "").split("\n")[0].slice(0, 120);
|
|
2727
2842
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2728
2843
|
className: TaskCommandNode_module_css_default.row,
|
|
2729
2844
|
"data-variant": "ok",
|
|
2730
2845
|
children: [
|
|
2731
2846
|
"/insight ",
|
|
2732
|
-
|
|
2847
|
+
insightVerb,
|
|
2733
2848
|
" ",
|
|
2734
2849
|
note || "已完成"
|
|
2735
2850
|
]
|
|
@@ -2798,11 +2913,14 @@ window.__ModuleLoader__.load({
|
|
|
2798
2913
|
return null;
|
|
2799
2914
|
}
|
|
2800
2915
|
/** 把 `show_task_panel` 的视图注册进宿主的 `tool.call.toolview` 槽。 */
|
|
2801
|
-
function registerShowTaskPanelView(slots) {
|
|
2802
|
-
slots.inject("tool.call.toolview", () =>
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2916
|
+
function registerShowTaskPanelView(slots, keep) {
|
|
2917
|
+
slots.inject("tool.call.toolview", () => {
|
|
2918
|
+
const off = slots.register({
|
|
2919
|
+
name: "tool.call.toolview",
|
|
2920
|
+
key: "show_task_panel"
|
|
2921
|
+
}, ShowTaskPanelNode);
|
|
2922
|
+
if (typeof keep === "function") keep(off);
|
|
2923
|
+
});
|
|
2806
2924
|
}
|
|
2807
2925
|
//#endregion
|
|
2808
2926
|
//#region src/client/slash.ts
|
|
@@ -3008,33 +3126,49 @@ window.__ModuleLoader__.load({
|
|
|
3008
3126
|
* @param ctx - client 根上下文
|
|
3009
3127
|
*/
|
|
3010
3128
|
function registerTaskPanel(ctx) {
|
|
3011
|
-
const mount = (slots) => {
|
|
3129
|
+
const mount = (slots, effect) => {
|
|
3012
3130
|
if (!slots || typeof slots.inject !== "function") {
|
|
3013
3131
|
console.warn(`[${NS}] host has no slots service — task panel disabled`);
|
|
3014
3132
|
return;
|
|
3015
3133
|
}
|
|
3134
|
+
const keep = (off) => {
|
|
3135
|
+
if (typeof off !== "function") return;
|
|
3136
|
+
const dispose = () => {
|
|
3137
|
+
try {
|
|
3138
|
+
off();
|
|
3139
|
+
} catch {}
|
|
3140
|
+
};
|
|
3141
|
+
if (typeof effect === "function") effect(() => dispose);
|
|
3142
|
+
};
|
|
3143
|
+
const register = (spec, component) => {
|
|
3144
|
+
try {
|
|
3145
|
+
keep(slots.register(spec, component));
|
|
3146
|
+
} catch (err) {
|
|
3147
|
+
console.warn(`[${NS}] slot registration failed:`, err);
|
|
3148
|
+
}
|
|
3149
|
+
};
|
|
3016
3150
|
try {
|
|
3017
|
-
slots.inject("shell.overlay", () =>
|
|
3151
|
+
slots.inject("shell.overlay", () => register({
|
|
3018
3152
|
name: "shell.overlay",
|
|
3019
3153
|
id: "dsh-project-memory-task-panel",
|
|
3020
3154
|
order: 100
|
|
3021
3155
|
}, () => (0, react.createElement)(TaskPanelEntry, { ctx })));
|
|
3022
|
-
for (const key of ["tasks"]) slots.inject("conversation.chat.commandview", () =>
|
|
3156
|
+
for (const key of ["tasks"]) slots.inject("conversation.chat.commandview", () => register({
|
|
3023
3157
|
name: "conversation.chat.commandview",
|
|
3024
3158
|
key
|
|
3025
3159
|
}, TaskCommandNode));
|
|
3026
|
-
registerShowTaskPanelView(slots);
|
|
3160
|
+
registerShowTaskPanelView(slots, keep);
|
|
3027
3161
|
} catch (err) {
|
|
3028
3162
|
console.warn(`[${NS}] task panel registration failed:`, err);
|
|
3029
3163
|
}
|
|
3030
3164
|
};
|
|
3031
3165
|
if (typeof ctx?.inject === "function") try {
|
|
3032
|
-
ctx.inject(["slots"], (scope) => mount(scope?.slots ?? service(ctx, "slots")));
|
|
3166
|
+
ctx.inject(["slots"], (scope) => mount(scope?.slots ?? service(ctx, "slots"), scope?.effect));
|
|
3033
3167
|
return;
|
|
3034
3168
|
} catch (err) {
|
|
3035
3169
|
console.warn(`[${NS}] slots injection failed:`, err);
|
|
3036
3170
|
}
|
|
3037
|
-
mount(service(ctx, "slots"));
|
|
3171
|
+
mount(service(ctx, "slots"), typeof ctx?.effect === "function" ? ctx.effect.bind(ctx) : void 0);
|
|
3038
3172
|
}
|
|
3039
3173
|
/**
|
|
3040
3174
|
* 过了宽限期仍然读不到必需服务时,打**一条**点名缺失项的告警。
|