dsh-whale-pal 0.2.0 → 0.3.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/lib/client.js CHANGED
@@ -23,14 +23,17 @@ window.__ModuleLoader__.load({
23
23
  const CARD_PARSE_ROUTE = "api/whale-pal/card/parse";
24
24
  const CARD_SPLIT_ROUTE = "api/whale-pal/card/split";
25
25
  const WORKSPACES_ROUTE = "api/whale-pal/workspaces";
26
+ const SCENE_ROUTE = "api/whale-pal/scene";
26
27
 
27
28
  /** 空值统一口径。 */
28
29
  const EMPTY = "还没写 · 想起来再说";
29
30
 
30
- /** 宿主收的键:三个设施项 + 一个称呼开关 + 人格卡十一项 + 原文存档。多一个都会退回来。 */
31
+ /** 宿主收的键:五个设施项 + 一个称呼开关 + 人格卡十一项 + 原文存档。多一个都会退回来。 */
31
32
  const ALLOWED_KEYS = [
32
33
  "vaultPath",
34
+ "workRoot",
33
35
  "obsidianEnabled",
36
+ "personaEnabled",
34
37
  "rejectServileAddress",
35
38
  "whaleWorkspaces",
36
39
  "name",
@@ -93,7 +96,11 @@ window.__ModuleLoader__.load({
93
96
  const ERROR_COPY = {
94
97
  "vaultPath-not-a-directory": "这个目录不存在,我不知道你的笔记在哪",
95
98
  "vaultPath-not-absolute": "这个路径没从盘符或根目录开始,我看不懂",
99
+ "workRoot-not-a-directory": "这个目录不存在,我不知道任务工作区该建在哪",
100
+ "workRoot-not-absolute": "这个路径没从盘符或根目录开始,我看不懂",
101
+ "workRoot-no-access": "这个目录我打不开,权限不让",
96
102
  "obsidianEnabled-not-boolean": "这个开关只认开和关,别的值我没存",
103
+ "personaEnabled-not-boolean": "人格开关只认开和关,别的值我没存",
97
104
  "rejectServileAddress-not-boolean": "称呼那个开关只认开和关,别的值我没存",
98
105
  "whaleWorkspaces-not-array": "工作区名单得是一个列表,我没存",
99
106
  "whaleWorkspaces-not-string": "名单里有一项不是路径,我没存",
@@ -312,6 +319,33 @@ window.__ModuleLoader__.load({
312
319
  return { ok: true, data: payload };
313
320
  }
314
321
 
322
+ /**
323
+ * 记忆分层的四个动作:挪一条记忆、把目录并到项目、改场景名、决定那条「通用层满了」的请求。
324
+ * 走一条独立路由:它不是配置,改的是状态(和 /settings 的白名单不是一回事)。
325
+ */
326
+ async function postScene(action) {
327
+ let response;
328
+ try {
329
+ response = await fetch(SCENE_ROUTE, {
330
+ method: "POST",
331
+ headers: { "content-type": "application/json" },
332
+ body: JSON.stringify(isObject(action) ? action : {})
333
+ });
334
+ } catch (error) {
335
+ return { ok: false, message: "这个页面没连上宿主,这次没动" };
336
+ }
337
+ let payload = null;
338
+ try {
339
+ payload = await response.json();
340
+ } catch (error) {
341
+ payload = null;
342
+ }
343
+ if (response.ok === false) return { ok: false, message: readWriteError(payload, response.status) };
344
+ if (isObject(payload) === false) return { ok: false, message: "宿主回的是一段我看不懂的东西,这次没动" };
345
+ if (payload.ok === false) return { ok: false, message: readWriteError(payload, response.status) };
346
+ return { ok: true, data: payload };
347
+ }
348
+
315
349
  /**
316
350
  * 让宿主弹一个目录选择窗口。
317
351
  *
@@ -551,7 +585,7 @@ window.__ModuleLoader__.load({
551
585
  */
552
586
  function WhalePalSection(props) {
553
587
  const [snapshot, setSnapshot] = react.useState({ phase: "loading", data: null, message: "" });
554
- const [draft, setDraft] = react.useState({ vaultPath: "" });
588
+ const [draft, setDraft] = react.useState({ vaultPath: "", workRoot: "" });
555
589
  /** 换库时要不要把旧库的台账和上下文复制过来:默认要,取消勾选就只改指向。 */
556
590
  const [moveOnSwitch, setMoveOnSwitch] = react.useState(true);
557
591
  /** 粘贴区的原文,以及拆出来的十一项草稿(没写入前只在本页活着)。 */
@@ -569,9 +603,12 @@ window.__ModuleLoader__.load({
569
603
  const [workspaces, setWorkspaces] = react.useState([]);
570
604
  const [workspaceChoice, setWorkspaceChoice] = react.useState("");
571
605
  const [workspaceInput, setWorkspaceInput] = react.useState("");
606
+ /** 记忆分层:要挪的那条、挪去哪、要并进项目的目录。 */
607
+ const [sceneDraft, setSceneDraft] = react.useState({ id: "", target: "", dir: "", project: "" });
572
608
 
573
609
  const seed = (data) => ({
574
- vaultPath: valueOf(fieldOf(data, "vaultPath"))
610
+ vaultPath: valueOf(fieldOf(data, "vaultPath")),
611
+ workRoot: valueOf(fieldOf(data, "workRoot"))
575
612
  });
576
613
 
577
614
  const reload = () => {
@@ -612,7 +649,17 @@ window.__ModuleLoader__.load({
612
649
  const moved = result.migrated && result.migrated.moved && result.migrated.moved.length > 0
613
650
  ? "。台账和上下文搬过来了(" + result.migrated.total.files + " 个文件),旧库还在原地"
614
651
  : "";
615
- setNotice({ kind: "ok", text: doneCopy + moved + extra });
652
+ // 换总路径只换指向、不搬任何文件;指挥部跟着新路径固定建一个。
653
+ // 两句都只在真的发生时才说,没换路径的人不用看。
654
+ const rootMoved = result.workRootMoved
655
+ ? "。工作区总路径换了,旧目录里的文件不会跟着搬,还是留在原处"
656
+ : "";
657
+ const chief = result.chief
658
+ ? (result.chief.ok === true
659
+ ? "。指挥部工作区已经在(" + result.chief.path + ")"
660
+ : "。指挥部工作区没建成:" + result.chief.message)
661
+ : "";
662
+ setNotice({ kind: "ok", text: doneCopy + moved + rootMoved + chief + extra });
616
663
  setSnapshot((previous) => {
617
664
  if (previous.phase === "ready") {
618
665
  return { phase: "ready", data: withPatch(previous.data, patch), message: "" };
@@ -631,7 +678,23 @@ window.__ModuleLoader__.load({
631
678
  */
632
679
  const saveWhaleWorkspaces = (list, verb) => save({ whaleWorkspaces: list }, "工作区" + verb + "了");
633
680
 
634
- const pick = () => {
681
+ /** 记忆分层的动作:挪一条、并一个目录、决定一条请求。做完整页重读,不在这边猜结果。 */
682
+ const runSceneAction = (action, doneCopy) => {
683
+ setBusy(true);
684
+ setNotice({ kind: "", text: "" });
685
+ return postScene(action).then((result) => {
686
+ setBusy(false);
687
+ if (result.ok === false) {
688
+ setNotice({ kind: "error", text: result.message });
689
+ return;
690
+ }
691
+ return reload().then(() => setNotice({ kind: "ok", text: doneCopy }));
692
+ });
693
+ };
694
+
695
+ // 选目录只有一个入口,但要能填两个格:笔记库和工作区总路径。
696
+ // 不传参就是笔记库(老调用点不用改),传 "workRoot" 就填派活那格。
697
+ const pick = (target = "vaultPath") => {
635
698
  setBusy(true);
636
699
  setNotice({ kind: "", text: "" });
637
700
  return pickFolder().then((result) => {
@@ -644,7 +707,11 @@ window.__ModuleLoader__.load({
644
707
  setNotice({ kind: "", text: "没选,路径没变" });
645
708
  return;
646
709
  }
647
- setDraft({ vaultPath: result.path });
710
+ if (target === "workRoot") {
711
+ setDraft({ ...draft, workRoot: result.path });
712
+ return save({ workRoot: result.path }, "工作区总路径存下了");
713
+ }
714
+ setDraft({ ...draft, vaultPath: result.path });
648
715
  const controls = moveOnSwitch === false ? { migrateVault: false } : null;
649
716
  return save({ vaultPath: result.path }, "路径存下了", controls);
650
717
  });
@@ -939,6 +1006,9 @@ window.__ModuleLoader__.load({
939
1006
  const obsidianField = fieldOf(data, "obsidianEnabled");
940
1007
  const workspaceField = fieldOf(data, "whaleWorkspaces");
941
1008
  const obsidianOn = obsidianField.value === true;
1009
+ // 人格总开关:老宿主没这一格当「开着」——关着才是要明说的状态。
1010
+ const personaField = fieldOf(data, "personaEnabled");
1011
+ const personaOn = personaField.value !== false;
942
1012
  // 称呼上的硬边界:不属于人格卡,是这台机器自己的立场。
943
1013
  const servileField = fieldOf(data, "rejectServileAddress");
944
1014
  const servileOn = servileField.value === true;
@@ -955,6 +1025,228 @@ window.__ModuleLoader__.load({
955
1025
  const given = Array.isArray(data.identity) ? data.identity.filter(isObject) : [];
956
1026
  const identityRows = given.length > 0 ? given : IDENTITY_FALLBACK;
957
1027
 
1028
+ // ---- 记忆分层(P4):现在在哪一层、有几层、每条为什么在这层、手动挪。
1029
+ // 数据全部来自 /status 的 view.scene;旧宿主没这一格就整段不渲染。
1030
+ const sceneView = isObject(data) && isObject(data.view) && isObject(data.view.scene) ? data.view.scene : null;
1031
+ const scenePools = sceneView !== null && Array.isArray(sceneView.pools) ? sceneView.pools : [];
1032
+ const sceneEntries = sceneView !== null && Array.isArray(sceneView.entries) ? sceneView.entries : [];
1033
+ const sceneRequests = sceneView !== null && Array.isArray(sceneView.requests) ? sceneView.requests : [];
1034
+ const sceneCurrent = sceneView !== null && isObject(sceneView.current) ? sceneView.current : null;
1035
+ const sceneNote = sceneView !== null && typeof sceneView.note === "string" ? sceneView.note : "";
1036
+ const sceneTotal = sceneView !== null && typeof sceneView.total === "number" ? sceneView.total : sceneEntries.length;
1037
+ const poolChoices = scenePools.map((pool) => ({
1038
+ value: plain(pool.id),
1039
+ label: plain(pool.label) + "(" + textOf(pool.count) + " 条)"
1040
+ }));
1041
+ const viaWords = {
1042
+ manual: "手动指定",
1043
+ marker: "按项目标记往上找",
1044
+ cwd: "按目录名",
1045
+ backup: "备份目录,并到被备份的那个项目",
1046
+ unresolved: "没认出来"
1047
+ };
1048
+ const currentDir = sceneCurrent !== null ? plain(sceneCurrent.cwd) : "";
1049
+ const currentSceneId = sceneCurrent !== null ? plain(sceneCurrent.scene) : "";
1050
+ const currentVia = sceneCurrent !== null ? viaWords[plain(sceneCurrent.via)] || "" : "";
1051
+ const currentPool = scenePools.find((pool) => plain(pool.id) === currentSceneId) || null;
1052
+ const currentLabel = currentSceneId === "" ? "没认出来,先落在主人层" : currentPool !== null ? plain(currentPool.label) : currentSceneId;
1053
+ const timeText = (value) => {
1054
+ const n = Number(value) || 0;
1055
+ if (n <= 0) return "";
1056
+ const date = new Date(n);
1057
+ return isNaN(date.getTime()) ? "" : date.toLocaleString();
1058
+ };
1059
+
1060
+ const sceneNodes = [];
1061
+ sceneNodes.push(
1062
+ react.createElement("div", { key: "scene-now", style: S.row }, [
1063
+ react.createElement("span", { key: "label", style: S.label }, "现在在哪"),
1064
+ react.createElement("span", { key: "value", style: S.value }, currentDir === "" ? "还没读到目录" : currentDir),
1065
+ react.createElement(
1066
+ "span",
1067
+ { key: "hint", style: S.hint },
1068
+ "归到:" + currentLabel + (currentVia === "" ? "" : "(" + currentVia + ")")
1069
+ )
1070
+ ])
1071
+ );
1072
+ for (let i = 0; i < scenePools.length; i += 1) {
1073
+ const pool = scenePools[i];
1074
+ const updated = timeText(pool.lastUpdatedAt);
1075
+ sceneNodes.push(
1076
+ react.createElement("div", { key: "pool-" + plain(pool.id) + "-" + String(i), style: S.row }, [
1077
+ react.createElement("span", { key: "label", style: S.label }, plain(pool.label)),
1078
+ react.createElement("span", { key: "value", style: S.value }, textOf(pool.count) + " 条"),
1079
+ updated === "" ? null : react.createElement("span", { key: "hint", style: S.hint }, "最后更新 " + updated)
1080
+ ])
1081
+ );
1082
+ }
1083
+ if (scenePools.length === 0) sceneNodes.push(emptyLine("scene-empty", "还没有记忆,也就还没有分层"));
1084
+
1085
+ // 群(P5):群记录里那条会话还认不认得。认不出来就是静默降级,这里必须看得见。
1086
+ const sceneGroups = sceneView !== null && Array.isArray(sceneView.groups) ? sceneView.groups : [];
1087
+ const sceneCheck = sceneView !== null && Array.isArray(sceneView.groupCheck) ? sceneView.groupCheck : [];
1088
+ for (let i = 0; i < sceneGroups.length; i += 1) {
1089
+ const group = sceneGroups[i];
1090
+ const status = sceneCheck.find((item) => plain(item.id) === plain(group.id)) || null;
1091
+ const broken = status !== null && status.ok !== true;
1092
+ sceneNodes.push(
1093
+ react.createElement("div", { key: "group-" + String(i), style: S.row }, [
1094
+ react.createElement("span", { key: "label", style: S.label }, plain(group.name) || plain(group.groupId)),
1095
+ react.createElement(
1096
+ "span",
1097
+ { key: "value", style: S.value },
1098
+ plain(group.sessionId) === "" ? "还没有会话" : "会话 " + plain(group.sessionId)
1099
+ ),
1100
+ broken
1101
+ ? react.createElement(
1102
+ "span",
1103
+ { key: "hint", style: S.hint },
1104
+ "这条会话认不出来了,群记忆正在退化成普通会话"
1105
+ )
1106
+ : null
1107
+ ])
1108
+ );
1109
+ }
1110
+
1111
+ // 挪一条:按编号指定,没列出来的也能操作;列表里给的是最近 200 条。
1112
+ const sceneRowStyle = { ...S.row, flexBasis: "100%" };
1113
+ const moveRow = react.createElement("div", { key: "scene-move", style: sceneRowStyle }, [
1114
+ react.createElement("span", { key: "label", style: S.label }, "挪一条记忆"),
1115
+ react.createElement("input", {
1116
+ key: "id",
1117
+ style: S.input,
1118
+ value: sceneDraft.id,
1119
+ placeholder: "编号,例如 M-042",
1120
+ onChange: (event) =>
1121
+ setSceneDraft({ ...sceneDraft, id: plain(event && typeof event.target === "object" ? event.target.value : "") })
1122
+ }),
1123
+ react.createElement(
1124
+ "select",
1125
+ {
1126
+ key: "target",
1127
+ style: S.input,
1128
+ value: sceneDraft.target,
1129
+ onChange: (event) =>
1130
+ setSceneDraft({ ...sceneDraft, target: plain(event && typeof event.target === "object" ? event.target.value : "") })
1131
+ },
1132
+ [react.createElement("option", { key: "", value: "" }, "挪到…")].concat(
1133
+ poolChoices.map((choice) =>
1134
+ react.createElement("option", { key: choice.value, value: choice.value }, choice.label)
1135
+ )
1136
+ )
1137
+ ),
1138
+ react.createElement("button", {
1139
+ key: "go",
1140
+ type: "button",
1141
+ style: S.button,
1142
+ disabled: busy || sceneDraft.id.trim() === "" || sceneDraft.target === "",
1143
+ onClick: () =>
1144
+ runSceneAction(
1145
+ { action: "move", id: sceneDraft.id.trim(), scene: sceneDraft.target },
1146
+ "挪好了"
1147
+ )
1148
+ }, "挪过去")
1149
+ ]);
1150
+
1151
+ // 把目录并到某个项目:改的是映射,下一次召回立刻按新归属走。
1152
+ const projectChoices = (Array.isArray(sceneView && sceneView.projects) ? sceneView.projects : []).map((project) => ({
1153
+ value: plain(project.id),
1154
+ label: plain(project.name) || plain(project.id)
1155
+ }));
1156
+ const mergeRow = react.createElement("div", { key: "scene-merge", style: sceneRowStyle }, [
1157
+ react.createElement("span", { key: "label", style: S.label }, "把目录并进项目"),
1158
+ react.createElement("input", {
1159
+ key: "dir",
1160
+ style: S.input,
1161
+ value: sceneDraft.dir,
1162
+ placeholder: currentDir === "" ? "目录路径" : currentDir,
1163
+ onChange: (event) =>
1164
+ setSceneDraft({ ...sceneDraft, dir: plain(event && typeof event.target === "object" ? event.target.value : "") })
1165
+ }),
1166
+ react.createElement(
1167
+ "select",
1168
+ {
1169
+ key: "target",
1170
+ style: S.input,
1171
+ value: sceneDraft.project || "",
1172
+ onChange: (event) =>
1173
+ setSceneDraft({ ...sceneDraft, project: plain(event && typeof event.target === "object" ? event.target.value : "") })
1174
+ },
1175
+ [react.createElement("option", { key: "", value: "" }, "并进…")].concat(
1176
+ projectChoices.map((choice) =>
1177
+ react.createElement("option", { key: choice.value, value: choice.value }, choice.label)
1178
+ )
1179
+ )
1180
+ ),
1181
+ react.createElement("button", {
1182
+ key: "go",
1183
+ type: "button",
1184
+ style: S.button,
1185
+ disabled: busy || (sceneDraft.dir.trim() === "" && currentDir === "") || (sceneDraft.project || "") === "",
1186
+ onClick: () =>
1187
+ runSceneAction(
1188
+ {
1189
+ action: "merge",
1190
+ dir: sceneDraft.dir.trim() === "" ? currentDir : sceneDraft.dir.trim(),
1191
+ scene: sceneDraft.project || ""
1192
+ },
1193
+ "并进去了"
1194
+ )
1195
+ }, "合并")
1196
+ ]);
1197
+ if (projectChoices.length > 0) sceneNodes.push(mergeRow);
1198
+ if (poolChoices.length > 0) sceneNodes.push(moveRow);
1199
+
1200
+ // 「通用层满了」的那些请求:不自己丢,等人决定。
1201
+ for (let i = 0; i < sceneRequests.length; i += 1) {
1202
+ const request = sceneRequests[i];
1203
+ sceneNodes.push(
1204
+ react.createElement("div", { key: "request-" + String(i), style: S.row }, [
1205
+ react.createElement("span", { key: "label", style: S.label }, plain(request.sceneLabel)),
1206
+ react.createElement("span", { key: "value", style: S.value }, plain(request.text)),
1207
+ react.createElement("span", { key: "hint", style: S.hint }, "满了,等你决定"),
1208
+ react.createElement("button", {
1209
+ key: "yes",
1210
+ type: "button",
1211
+ style: S.button,
1212
+ disabled: busy,
1213
+ onClick: () =>
1214
+ runSceneAction({ action: "decide", scene: plain(request.scene), text: plain(request.text), accept: true }, "放进去了")
1215
+ }, "放进这一层"),
1216
+ react.createElement("button", {
1217
+ key: "no",
1218
+ type: "button",
1219
+ style: S.button,
1220
+ disabled: busy,
1221
+ onClick: () =>
1222
+ runSceneAction({ action: "decide", scene: plain(request.scene), text: plain(request.text), accept: false }, "算了")
1223
+ }, "算了")
1224
+ ])
1225
+ );
1226
+ }
1227
+
1228
+ // 每条记忆为什么在这一层:最近 200 条,带编号、层、理由。
1229
+ for (let i = 0; i < sceneEntries.length; i += 1) {
1230
+ const entry = sceneEntries[i];
1231
+ sceneNodes.push(
1232
+ react.createElement("div", { key: "entry-" + String(i), style: S.row }, [
1233
+ react.createElement("span", { key: "label", style: S.label }, plain(entry.id) || "无编号"),
1234
+ react.createElement("span", { key: "value", style: S.value }, plain(entry.text)),
1235
+ react.createElement("span", { key: "hint", style: S.hint }, plain(entry.sceneLabel) + " · " + plain(entry.why))
1236
+ ])
1237
+ );
1238
+ }
1239
+ if (sceneEntries.length > 0 && sceneTotal > sceneEntries.length) {
1240
+ sceneNodes.push(
1241
+ emptyLine(
1242
+ "scene-more",
1243
+ "这里列了最近 " + String(sceneEntries.length) + " 条,还有 " + String(sceneTotal - sceneEntries.length) + " 条没列出来;按编号仍然能挪"
1244
+ )
1245
+ );
1246
+ }
1247
+ if (sceneNote !== "") sceneNodes.push(emptyLine("scene-note", sceneNote));
1248
+
1249
+
958
1250
  // 动作的结果贴在视口底部。这一页很长,提示若摆在顶部,人在下面点完按钮
959
1251
  // 根本看不到(2026-11-11 用户反馈「点了写入没有提示」)。写入中先说一声。
960
1252
  const toastText = busy ? "写入中…" : notice.text;
@@ -1037,7 +1329,25 @@ window.__ModuleLoader__.load({
1037
1329
  type: "button",
1038
1330
  style: S.button,
1039
1331
  disabled: busy || pickerAvailable === false,
1040
- onClick: pick
1332
+ onClick: () => pick("vaultPath")
1333
+ },
1334
+ "选目录"
1335
+ )
1336
+ ]);
1337
+
1338
+ // 工作区总路径:派活时按项目名在这儿建目录。跟笔记库一样只给「选」不给打,
1339
+ // 理由相同——手拼路径是这套东西里最容易错的一步。
1340
+ const workRootRow = react.createElement("div", { key: "workRoot", style: S.row }, [
1341
+ react.createElement("span", { key: "label", style: S.label }, "工作区总路径"),
1342
+ react.createElement("span", { key: "value", style: S.value }, draft.workRoot === "" ? "" : draft.workRoot),
1343
+ react.createElement(
1344
+ "button",
1345
+ {
1346
+ key: "pick",
1347
+ type: "button",
1348
+ style: S.button,
1349
+ disabled: busy || pickerAvailable === false,
1350
+ onClick: () => pick("workRoot")
1041
1351
  },
1042
1352
  "选目录"
1043
1353
  )
@@ -1060,6 +1370,31 @@ window.__ModuleLoader__.load({
1060
1370
  react.createElement("span", { key: "hint", style: S.hint }, "只复制,旧库不动")
1061
1371
  ]);
1062
1372
 
1373
+ // 人格总开关:关掉之后只留记忆与上下文压缩,人格 / 模式 / 进度三段不再进提示词。
1374
+ // 不删任何数据——卡片、记忆、档案都还在盘上,随时能再打开。
1375
+ const personaRow = react.createElement("div", { key: "personaSwitch", style: S.row }, [
1376
+ react.createElement("span", { key: "label", style: S.label }, "人格功能"),
1377
+ react.createElement("span", { key: "value", style: S.value }, personaOn ? "开着" : "关着"),
1378
+ react.createElement(
1379
+ "button",
1380
+ {
1381
+ key: "toggle",
1382
+ type: "button",
1383
+ style: S.button,
1384
+ disabled: busy,
1385
+ onClick: () => save({ personaEnabled: personaOn === false }, personaOn ? "关掉了" : "打开了")
1386
+ },
1387
+ personaOn ? "关掉人格" : "打开人格"
1388
+ ),
1389
+ react.createElement(
1390
+ "span",
1391
+ { key: "hint", style: S.hint },
1392
+ personaOn
1393
+ ? "现在开着:人格卡、模式、进度会写进系统提示。关掉后这几段不再出现,记忆和上下文压缩照常跑"
1394
+ : "现在关着:插件只做记忆和上下文压缩,人格交给别的插件。一条数据都没删,随时能再打开"
1395
+ )
1396
+ ]);
1397
+
1063
1398
  const obsidianRow = react.createElement("div", { key: "obsidian", style: S.row }, [
1064
1399
  react.createElement("span", { key: "label", style: S.label }, "Obsidian 联动"),
1065
1400
  react.createElement("span", { key: "value", style: S.value }, obsidianOn ? "开着" : "关着"),
@@ -1242,32 +1577,6 @@ window.__ModuleLoader__.load({
1242
1577
  ])
1243
1578
  );
1244
1579
 
1245
- const imported = isObject(data) && isObject(data.imported) ? data.imported : null;
1246
- const importedNodes = [];
1247
- if (imported === null) {
1248
- importedNodes.push(emptyLine("imported-empty", EMPTY));
1249
- } else {
1250
- const origin = plain(imported.from);
1251
- const at = plain(imported.at);
1252
- importedNodes.push(
1253
- react.createElement(
1254
- "p",
1255
- { key: "imported-from", style: S.lead },
1256
- origin === "" ? EMPTY : "从 " + origin + " 接手" + (at === "" ? "" : ",时间 " + at)
1257
- )
1258
- );
1259
- const diff = Array.isArray(imported.diff) ? imported.diff : [];
1260
- if (diff.length === 0) {
1261
- importedNodes.push(emptyLine("imported-diff", "没有要改的差异"));
1262
- } else {
1263
- const lines = diff.map((item, index) => {
1264
- const described = isObject(item) === true ? plain(item.label) || plain(item.text) || plain(item.note) : plain(item);
1265
- return react.createElement("p", { key: "diff-" + String(index), style: S.lead }, described === "" ? "一条差异" : described);
1266
- });
1267
- importedNodes.push(react.createElement("div", { key: "diff-list", style: S.group }, lines));
1268
- }
1269
- }
1270
-
1271
1580
  const health = isObject(data) && isObject(data.health) ? data.health : null;
1272
1581
  const healthState = health && typeof health.state === "string" ? health.state : "";
1273
1582
  const healthWords = { normal: "正常", readonly: "只读", disabled: "停用" };
@@ -1505,6 +1814,7 @@ window.__ModuleLoader__.load({
1505
1814
  ctxHint === "" ? null : react.createElement("span", { key: "hint", style: S.hint }, ctxHint),
1506
1815
  react.createElement("span", { key: "usage", style: S.hint }, ctxUsage),
1507
1816
  ]),
1817
+ groupElement("persona-switch", "人格开关", "关掉后插件只做记忆和上下文压缩,不再往系统提示里写人格。", [personaRow]),
1508
1818
  groupElement("card", "人格卡", "", cardNodes),
1509
1819
  groupElement("guard", "额外一条称呼规矩", "插件自己加的,不在人格卡里;默认关着。", [addressGuardRow]),
1510
1820
  groupElement("vault", "笔记库", "", [
@@ -1522,9 +1832,30 @@ window.__ModuleLoader__.load({
1522
1832
  obsidianStateRow,
1523
1833
  obsidianNoVaultHint
1524
1834
  ]),
1525
- groupElement("workspaces", "工作区模式", "列在这儿的工作区走鲸鲸模式,其余一律助手模式。", [workspaceRow]),
1835
+ groupElement("workroot", "任务工作区", "派活时按项目名在这里建目录,一个项目一个子目录;空着就没法派。", [
1836
+ workRootRow,
1837
+ pickerAvailable === false
1838
+ ? react.createElement(
1839
+ "span",
1840
+ { key: "workroot-picker-hint", style: S.hint },
1841
+ "这台机器没给我选目录的窗口,路径可以直接粘进来"
1842
+ )
1843
+ : null,
1844
+ draft.workRoot === "" ? emptyLine("workRoot-empty", "还没设。派活前先选一个目录") : null
1845
+ ]),
1846
+ groupElement(
1847
+ "workspaces",
1848
+ "工作区模式",
1849
+ "列在这儿的工作区走鲸鲸模式,其余一律助手模式;新会话起手选了「鲸鲸」预设的,不看目录也走鲸鲸。",
1850
+ [workspaceRow]
1851
+ ),
1526
1852
  groupElement("accounting", "记了多少", "这些是现在的底数,改了也不会在这里显示新值。", accountingRows),
1527
- groupElement("imported", "接手记录", "", importedNodes),
1853
+ groupElement(
1854
+ "scene",
1855
+ "记忆分层",
1856
+ "记忆按场景分开,各有各的名额;这儿看得见它归在哪一层、为什么。",
1857
+ sceneNodes
1858
+ ),
1528
1859
  react.createElement("div", { key: "footer", style: S.row }, [
1529
1860
  react.createElement("button", { key: "reload", type: "button", style: S.button, disabled: busy, onClick: reload }, "再读一次")
1530
1861
  ]),
package/lib/copy.js CHANGED
@@ -97,10 +97,47 @@ export const COPY = Object.freeze({
97
97
  vaultPathNotAbsolute: '这个路径没从盘符或根目录开始,我看不懂',
98
98
  vaultPathNotDirectory: '这个路径不是文件夹,我这边要的是笔记库的目录',
99
99
  vaultPathNoAccess: '这个目录我打不开,权限不让',
100
+ // 工作区总路径:同一套硬条件,文案说的是「任务工作区」,别让人以为在动笔记库。
101
+ workRootMissing: '这个目录不存在,我不知道任务工作区该建在哪',
102
+ workRootNotAbsolute: '这个路径没从盘符或根目录开始,我看不懂',
103
+ workRootNotDirectory: '这个路径不是文件夹,任务工作区得建在目录底下',
104
+ workRootNoAccess: '这个目录我打不开,权限不让',
105
+ workRootRequired: '还没设工作区总路径,派活不知道往哪建。先去设置页填上',
106
+ // 换总路径:不搬文件是定下来的做法,所以这句话得说出来,别让人以为项目跟着走了。
107
+ workRootMovedNotice: '工作区总路径换了。旧目录里的文件不会跟着搬,还是留在原处',
108
+ // 指挥部:总路径底下固定一个,名字写死。
109
+ chiefNoWorkRoot: '还没设工作区总路径,指挥部不知道该建在哪',
110
+ chiefNoRegistry: '宿主没给工作区注册表,指挥部建不了',
111
+ chiefMkdirFailed: '指挥部目录没建出来',
112
+ chiefFailed: '指挥部工作区没注册上',
113
+
114
+ // ---- 派活
115
+ dispatchToolName: 'whale_pal_dispatch',
116
+ dispatchBadName: '项目名或任务名是空的,或者里面有当不了文件夹名的字符。换个短一点、干净一点的名字再派',
117
+ dispatchVaultMissing: '记忆空间路径还没设,任务文档不知道写哪。先去设置页填上',
118
+ dispatchTaskExists: '这个项目下已经有同名任务的产出目录了,不合并。换个任务名,或者先把旧目录挪走',
119
+ dispatchDocExists: '这个任务已经有任务文档了,不覆盖。要重写就在调用时明确说覆盖',
120
+ dispatchNoRegistry: '宿主没给工作区注册表,这次没派成',
121
+ dispatchNoController: '宿主没给会话控制器,这次没派成',
122
+ dispatchGivenDocNotAbsolute: '给的任务文档要给绝对路径',
123
+ dispatchGivenDocMissing: '给的任务文档路径不存在',
124
+ dispatchMkdirFailed: '目录没建出来,这次没派成',
125
+ dispatchDocWriteFailed: '任务文档没写进去,这次没派成',
126
+ dispatchWorkspaceFailed: '工作区没注册上,这次没派成',
127
+ dispatchCreateFailed: '会话没建出来,这次没派成',
128
+ dispatchPromptFailed: '会话建出来了,但首条消息没递进去。已经把这条空会话归档,免得侧栏多一条点进去是空的',
129
+ dispatchNoPermissionService: '宿主没给权限服务,这条会话按默认档跑;撞上沙箱那道墙它可能干等在那里,这次得盯着点',
130
+ dispatchNoPermissionSession: '没拿到刚建的会话,权限档没切成;撞上沙箱那道墙它可能干等在那里',
131
+ dispatchPermissionFailed: '权限档没切成你要的那一档,这条会话会按默认档跑,可能被沙箱挡住干等',
132
+ dispatchPermissionRequired:
133
+ '派活前没定权限档。先问用户这次给哪一档:完全放开(不卡沙箱,活能干完),还是只能写工作区(更安全,但 Windows 上新目录可能第一条命令就卡在写权限上)。没选就不派',
134
+ dispatchPermissionInvalid:
135
+ '权限档只认两档:完全放开、只能写工作区。别传别的值,也别自己改一档出来',
100
136
  vaultMigrateFailed: '新库没搬成,路径没改。旧库还是原来的,一个字节没动',
101
137
  vaultMigrateBusy: '新库里已经有台账或上下文,里面不是空的。我不合并也不覆盖,先把那边挪开或换个库',
102
138
  obsidianNotBoolean: '这个开关只认开和关,别的值我没存',
103
139
  rejectServileNotBoolean: '称呼那个开关只认开和关,别的值我没存',
140
+ personaToggleNotBoolean: '人格开关只认开和关,别的值我没存',
104
141
  bodyNotJson: '这段内容不是 JSON,我没动设置',
105
142
  bodyTooLarge: '这段话太长,我没收',
106
143
  modeUnknown: '模式只有 assistant 和 whale 两种',
@@ -126,7 +163,7 @@ export const COPY = Object.freeze({
126
163
 
127
164
  // ---- 鲸鲸工作区(设置页那一块)
128
165
  labelWhaleWorkspaces: '鲸鲸工作区',
129
- whaleWorkspacesHint: '列在这儿的目录走鲸鲸模式,其余目录一律助手模式',
166
+ whaleWorkspacesHint: '列在这儿的目录走鲸鲸模式,其余目录一律助手模式;新会话起手选了「鲸鲸」预设也算鲸鲸',
130
167
  whaleWorkspacesEmpty: '还没选。选一个目录当聊天的地儿,或者手动填路径',
131
168
  whaleWorkspacesUnreadable: '读不到工作区列表,可以在下面手动填一个路径',
132
169
  actionAddWorkspace: '加入',
@@ -179,11 +216,11 @@ export const COPY = Object.freeze({
179
216
  importNoPreRollback: '没有 pre-rollback 快照,退不回来',
180
217
  importNeedsForce: '导入后新根又住下了,回滚会丢东西;把「确认」带上再来一次',
181
218
  importRollbackFailed: '这次没退成,盘上没动干净,看日志',
182
- // 台账与节律(P4):`/whale ledger` 那一家的回话。
219
+ // 台账(P4):`/whale ledger` 那一家的回话。
183
220
  ledgerOff: '台账没挂上(看启动日志),这会儿读不了',
184
221
  ledgerNoVault: '没设库,台账没处写——先去设置页把库目录填上',
185
- ledgerQuiet: '现在没什么要说的',
186
- ledgerUnknown: 'ledger 只认 status(或什么都不带)、preview、handoffs、fills、settle <行号> [ignore]、fallback <日|周|月> <值>',
222
+ ledgerScanQuiet: '扫了一遍:没有过期承诺,也没欠着的事',
223
+ ledgerUnknown: 'ledger 只认 status(或什么都不带)、scan、handoffs、fills、settle <行号> [ignore]',
187
224
  })
188
225
 
189
226
  const BANNED = Object.freeze(['请', '务必', '注意', '温馨提示', '哦', '啦', '呢', '!', '抱歉', '感谢理解'])