@chenhw7/dsh-memory 0.1.3 → 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.
Files changed (75) hide show
  1. package/README.md +101 -120
  2. package/README.zh-CN.md +103 -119
  3. package/cordis.patch.yml +13 -8
  4. package/lib/client/index.js +616 -185
  5. package/lib/context/conflict.d.ts +19 -2
  6. package/lib/context/conflict.d.ts.map +1 -1
  7. package/lib/context/conflict.js +33 -0
  8. package/lib/context/conflict.js.map +1 -1
  9. package/lib/context/index.d.ts +34 -10
  10. package/lib/context/index.d.ts.map +1 -1
  11. package/lib/context/index.js +195 -24
  12. package/lib/context/index.js.map +1 -1
  13. package/lib/context/policy.d.ts +28 -1
  14. package/lib/context/policy.d.ts.map +1 -1
  15. package/lib/context/policy.js +60 -3
  16. package/lib/context/policy.js.map +1 -1
  17. package/lib/index.d.ts +27 -7
  18. package/lib/index.d.ts.map +1 -1
  19. package/lib/index.js +22 -0
  20. package/lib/index.js.map +1 -1
  21. package/lib/notes/index.d.ts +66 -0
  22. package/lib/notes/index.d.ts.map +1 -0
  23. package/lib/notes/index.js +180 -0
  24. package/lib/notes/index.js.map +1 -0
  25. package/lib/notes/render.d.ts +32 -0
  26. package/lib/notes/render.d.ts.map +1 -0
  27. package/lib/notes/render.js +68 -0
  28. package/lib/notes/render.js.map +1 -0
  29. package/lib/notes/scope.d.ts +35 -0
  30. package/lib/notes/scope.d.ts.map +1 -0
  31. package/lib/notes/scope.js +44 -0
  32. package/lib/notes/scope.js.map +1 -0
  33. package/lib/notes/settings.d.ts +35 -0
  34. package/lib/notes/settings.d.ts.map +1 -0
  35. package/lib/notes/settings.js +36 -0
  36. package/lib/notes/settings.js.map +1 -0
  37. package/lib/notes/writer.d.ts +32 -0
  38. package/lib/notes/writer.d.ts.map +1 -0
  39. package/lib/notes/writer.js +71 -0
  40. package/lib/notes/writer.js.map +1 -0
  41. package/lib/review/accumulator.d.ts +53 -18
  42. package/lib/review/accumulator.d.ts.map +1 -1
  43. package/lib/review/accumulator.js +176 -36
  44. package/lib/review/accumulator.js.map +1 -1
  45. package/lib/review/dedup.d.ts +16 -3
  46. package/lib/review/dedup.d.ts.map +1 -1
  47. package/lib/review/dedup.js +21 -4
  48. package/lib/review/dedup.js.map +1 -1
  49. package/lib/review/extract.d.ts +81 -5
  50. package/lib/review/extract.d.ts.map +1 -1
  51. package/lib/review/extract.js +224 -31
  52. package/lib/review/extract.js.map +1 -1
  53. package/lib/review/index.d.ts +15 -2
  54. package/lib/review/index.d.ts.map +1 -1
  55. package/lib/review/index.js +137 -55
  56. package/lib/review/index.js.map +1 -1
  57. package/lib/scanner.d.ts +15 -0
  58. package/lib/scanner.d.ts.map +1 -1
  59. package/lib/scanner.js +20 -0
  60. package/lib/scanner.js.map +1 -1
  61. package/lib/store/bm25.d.ts +48 -0
  62. package/lib/store/bm25.d.ts.map +1 -0
  63. package/lib/store/bm25.js +115 -0
  64. package/lib/store/bm25.js.map +1 -0
  65. package/lib/store/index.d.ts +26 -3
  66. package/lib/store/index.d.ts.map +1 -1
  67. package/lib/store/index.js +111 -68
  68. package/lib/store/index.js.map +1 -1
  69. package/lib/tool/index.d.ts +3 -1
  70. package/lib/tool/index.d.ts.map +1 -1
  71. package/lib/tool/index.js +52 -9
  72. package/lib/tool/index.js.map +1 -1
  73. package/lib/types.d.ts +17 -1
  74. package/lib/types.d.ts.map +1 -1
  75. package/package.json +35 -30
@@ -417,18 +417,129 @@ var cls = {
417
417
  };
418
418
  var css = (inject(), cls);
419
419
 
420
- // src/client/MemoryPluginCard.tsx
420
+ // src/client/fields.tsx
421
421
  var import_jsx_runtime = require("react/jsx-runtime");
422
+ function FieldHead(props) {
423
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.head, children: [
424
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { className: css.label, htmlFor: props.id, children: props.label }),
425
+ props.overridden ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: css.badges, children: [
426
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: css.badge, children: props.overriddenLabel }),
427
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: css.reset, disabled: props.disabled, onClick: props.onReset, children: props.resetLabel })
428
+ ] }) : null
429
+ ] });
430
+ }
431
+ function SelectField(props) {
432
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.field, children: [
433
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldHead, { ...props }),
434
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
435
+ "select",
436
+ {
437
+ id: props.id,
438
+ className: css.select,
439
+ value: props.value,
440
+ disabled: props.disabled,
441
+ onChange: (e) => props.onChange(e.target.value),
442
+ children: props.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: o.value, children: o.label }, o.value))
443
+ }
444
+ ),
445
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: css.hint, children: props.hint })
446
+ ] });
447
+ }
448
+ function TextField(props) {
449
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.field, children: [
450
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldHead, { ...props }),
451
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
452
+ "input",
453
+ {
454
+ id: props.id,
455
+ className: css.input,
456
+ type: "text",
457
+ value: props.value,
458
+ disabled: props.disabled,
459
+ onChange: (e) => props.onChange(e.target.value)
460
+ }
461
+ ),
462
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: css.hint, children: props.hint })
463
+ ] });
464
+ }
465
+ function NumberField(props) {
466
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.field, children: [
467
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldHead, { ...props }),
468
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
469
+ "input",
470
+ {
471
+ id: props.id,
472
+ className: props.invalid ? css.inputInvalid : css.input,
473
+ type: "text",
474
+ inputMode: "numeric",
475
+ ...props.invalid ? { "aria-invalid": true } : {},
476
+ value: String(props.value),
477
+ disabled: props.disabled,
478
+ onChange: (e) => props.onChange(e.target.value)
479
+ }
480
+ ),
481
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: props.invalid ? css.invalid : css.hint, children: props.invalid ? props.invalidLabel : props.hint })
482
+ ] });
483
+ }
484
+ function CheckboxField(props) {
485
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.field, children: [
486
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.head, children: [
487
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: css.checkRow, children: [
488
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
489
+ "input",
490
+ {
491
+ id: props.id,
492
+ type: "checkbox",
493
+ className: css.checkbox,
494
+ checked: props.checked,
495
+ disabled: props.disabled,
496
+ onChange: (e) => props.onChange(e.target.checked)
497
+ }
498
+ ),
499
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { className: css.checkLabel, htmlFor: props.id, children: props.label })
500
+ ] }),
501
+ props.overridden ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: css.badges, children: [
502
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: css.badge, children: props.overriddenLabel }),
503
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: css.reset, disabled: props.disabled, onClick: props.onReset, children: props.resetLabel })
504
+ ] }) : null
505
+ ] }),
506
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: css.hint, children: props.hint })
507
+ ] });
508
+ }
509
+ function TextareaField(props) {
510
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.field, children: [
511
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldHead, { ...props }),
512
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
513
+ "textarea",
514
+ {
515
+ id: props.id,
516
+ className: css.textarea,
517
+ value: props.value,
518
+ disabled: props.disabled,
519
+ rows: 4,
520
+ onChange: (e) => props.onChange(e.target.value)
521
+ }
522
+ ),
523
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: css.hint, children: props.hint })
524
+ ] });
525
+ }
526
+
527
+ // src/client/MemoryPluginCard.tsx
528
+ var import_jsx_runtime2 = require("react/jsx-runtime");
422
529
  var MODES = ["policy-only", "full", "index", "custom", "off"];
423
530
  var DEFAULTS = {
424
531
  memoryMode: "policy-only",
425
- reviewEnabled: true,
426
- reviewCandidateThreshold: 10,
427
- flushOnCompaction: true,
428
- flushOnDispose: true,
532
+ memoryPolicyCustomText: "",
429
533
  memoryCharLimit: 5e3,
430
- memoryPolicyCustomText: ""
534
+ maxSearchResults: 50,
535
+ decayDays: 30,
536
+ notesEnabled: true,
537
+ notesDir: "docs/agent-memory",
538
+ notesCharLimit: 4e3,
539
+ notesAgentsPointer: true,
540
+ notesMaxEntriesPerFile: 100
431
541
  };
542
+ var NUMERIC_FIELDS = ["memoryCharLimit", "maxSearchResults", "decayDays", "notesCharLimit", "notesMaxEntriesPerFile"];
432
543
  function isOverridden(snap, field) {
433
544
  const user = snap.user;
434
545
  if (user === void 0 || user === null || typeof user !== "object") return false;
@@ -452,12 +563,12 @@ function MemoryPluginCard(props) {
452
563
  };
453
564
  const numericInvalid = (field) => {
454
565
  const v = draft[field];
455
- if (v === void 0 || v === null || v === "") return false;
566
+ if (v === void 0 || v === null) return false;
456
567
  const n = Number(v);
457
568
  return !Number.isFinite(n) || n < 0;
458
569
  };
459
570
  const dirty = JSON.stringify(draft) !== JSON.stringify({ ...DEFAULTS, ...committed });
460
- const invalid = numericInvalid("reviewCandidateThreshold") || numericInvalid("memoryCharLimit");
571
+ const invalid = NUMERIC_FIELDS.some(numericInvalid);
461
572
  const disabled = !snap.writable;
462
573
  const blocked = !dirty || invalid || saving;
463
574
  if (snap.status !== "ready") return null;
@@ -482,8 +593,8 @@ function MemoryPluginCard(props) {
482
593
  setDraft({ ...DEFAULTS, ...committed });
483
594
  setFailed(false);
484
595
  };
485
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { className: `${css.card}${open ? ` ${css.cardOpen}` : ""}`, children: [
486
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
596
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("li", { className: `${css.card}${open ? ` ${css.cardOpen}` : ""}`, children: [
597
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
487
598
  "button",
488
599
  {
489
600
  type: "button",
@@ -494,18 +605,18 @@ function MemoryPluginCard(props) {
494
605
  setOpen(!open);
495
606
  },
496
607
  children: [
497
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: css.headText, children: [
498
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: css.name, children: t("cardTitle") }),
499
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: css.description, children: t("cardDescription") })
608
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: css.headText, children: [
609
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: css.name, children: t("cardTitle") }),
610
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: css.description, children: t("cardDescription") })
500
611
  ] }),
501
- dirty ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: css.pending, children: t("unsaved") }) : null,
502
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconChevronDownOutline14, { className: `${css.chevron}${open ? ` ${css.chevronOpen}` : ""}` })
612
+ dirty ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: css.pending, children: t("unsaved") }) : null,
613
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconChevronDownOutline14, { className: `${css.chevron}${open ? ` ${css.chevronOpen}` : ""}` })
503
614
  ]
504
615
  }
505
616
  ),
506
- open ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.body, children: [
507
- !snap.writable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: css.readOnly, role: "status", children: t("readOnly") }) : null,
508
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
617
+ open ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: css.body, children: [
618
+ !snap.writable ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: css.readOnly, role: "status", children: t("readOnly") }) : null,
619
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
509
620
  SelectField,
510
621
  {
511
622
  id: "dsh-memory-mode",
@@ -524,7 +635,7 @@ function MemoryPluginCard(props) {
524
635
  }
525
636
  }
526
637
  ),
527
- draft.memoryMode === "custom" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
638
+ draft.memoryMode === "custom" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
528
639
  TextareaField,
529
640
  {
530
641
  id: "dsh-memory-custom-policy",
@@ -542,201 +653,331 @@ function MemoryPluginCard(props) {
542
653
  }
543
654
  }
544
655
  ) : null,
545
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
546
- CheckboxField,
547
- {
548
- id: "dsh-memory-review-enabled",
549
- label: t("reviewEnabled"),
550
- hint: t("reviewEnabledHint"),
551
- overridden: isOverridden(snap, "reviewEnabled"),
552
- overriddenLabel: t("overridden"),
553
- resetLabel: t("reset"),
554
- disabled,
555
- checked: Boolean(draft.reviewEnabled ?? true),
556
- onChange: (v) => edit("reviewEnabled", v),
557
- onReset: () => {
558
- void props.unset("reviewEnabled");
559
- edit("reviewEnabled", void 0);
560
- }
561
- }
562
- ),
563
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
656
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
564
657
  NumberField,
565
658
  {
566
- id: "dsh-memory-review-threshold",
567
- label: t("reviewThreshold"),
568
- hint: t("reviewThresholdHint"),
569
- overridden: isOverridden(snap, "reviewCandidateThreshold"),
659
+ id: "dsh-memory-char-limit",
660
+ label: t("charLimit"),
661
+ hint: t("charLimitHint"),
662
+ overridden: isOverridden(snap, "memoryCharLimit"),
570
663
  overriddenLabel: t("overridden"),
571
664
  resetLabel: t("reset"),
572
665
  invalidLabel: t("invalidNumber"),
573
- invalid: numericInvalid("reviewCandidateThreshold"),
574
- disabled,
575
- value: draft.reviewCandidateThreshold ?? "",
576
- onChange: (v) => edit("reviewCandidateThreshold", v === "" ? void 0 : Number(v)),
577
- onReset: () => {
578
- void props.unset("reviewCandidateThreshold");
579
- edit("reviewCandidateThreshold", void 0);
580
- }
581
- }
582
- ),
583
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
584
- CheckboxField,
585
- {
586
- id: "dsh-memory-flush-compaction",
587
- label: t("flushOnCompaction"),
588
- hint: t("flushOnCompactionHint"),
589
- overridden: isOverridden(snap, "flushOnCompaction"),
590
- overriddenLabel: t("overridden"),
591
- resetLabel: t("reset"),
666
+ invalid: numericInvalid("memoryCharLimit"),
592
667
  disabled,
593
- checked: Boolean(draft.flushOnCompaction ?? true),
594
- onChange: (v) => edit("flushOnCompaction", v),
668
+ value: draft.memoryCharLimit ?? "",
669
+ onChange: (v) => edit("memoryCharLimit", v === "" ? void 0 : Number(v)),
595
670
  onReset: () => {
596
- void props.unset("flushOnCompaction");
597
- edit("flushOnCompaction", void 0);
671
+ void props.unset("memoryCharLimit");
672
+ edit("memoryCharLimit", void 0);
598
673
  }
599
674
  }
600
675
  ),
601
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
602
- CheckboxField,
676
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
677
+ NumberField,
603
678
  {
604
- id: "dsh-memory-flush-dispose",
605
- label: t("flushOnDispose"),
606
- hint: t("flushOnDisposeHint"),
607
- overridden: isOverridden(snap, "flushOnDispose"),
679
+ id: "dsh-memory-max-search",
680
+ label: t("maxSearchResults"),
681
+ hint: t("maxSearchResultsHint"),
682
+ overridden: isOverridden(snap, "maxSearchResults"),
608
683
  overriddenLabel: t("overridden"),
609
684
  resetLabel: t("reset"),
685
+ invalidLabel: t("invalidNumber"),
686
+ invalid: numericInvalid("maxSearchResults"),
610
687
  disabled,
611
- checked: Boolean(draft.flushOnDispose ?? true),
612
- onChange: (v) => edit("flushOnDispose", v),
688
+ value: draft.maxSearchResults ?? "",
689
+ onChange: (v) => edit("maxSearchResults", v === "" ? void 0 : Number(v)),
613
690
  onReset: () => {
614
- void props.unset("flushOnDispose");
615
- edit("flushOnDispose", void 0);
691
+ void props.unset("maxSearchResults");
692
+ edit("maxSearchResults", void 0);
616
693
  }
617
694
  }
618
695
  ),
619
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
696
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
620
697
  NumberField,
621
698
  {
622
- id: "dsh-memory-char-limit",
623
- label: t("charLimit"),
624
- hint: t("charLimitHint"),
625
- overridden: isOverridden(snap, "memoryCharLimit"),
699
+ id: "dsh-memory-decay-days",
700
+ label: t("decayDays"),
701
+ hint: t("decayDaysHint"),
702
+ overridden: isOverridden(snap, "decayDays"),
626
703
  overriddenLabel: t("overridden"),
627
704
  resetLabel: t("reset"),
628
705
  invalidLabel: t("invalidNumber"),
629
- invalid: numericInvalid("memoryCharLimit"),
706
+ invalid: numericInvalid("decayDays"),
630
707
  disabled,
631
- value: draft.memoryCharLimit ?? "",
632
- onChange: (v) => edit("memoryCharLimit", v === "" ? void 0 : Number(v)),
708
+ value: draft.decayDays ?? "",
709
+ onChange: (v) => edit("decayDays", v === "" ? void 0 : Number(v)),
633
710
  onReset: () => {
634
- void props.unset("memoryCharLimit");
635
- edit("memoryCharLimit", void 0);
711
+ void props.unset("decayDays");
712
+ edit("decayDays", void 0);
636
713
  }
637
714
  }
638
715
  ),
639
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.footer, children: [
640
- failed ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: css.failed, role: "status", children: t("saveFailed") }) : null,
641
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: css.discard, disabled: !dirty || saving, onClick: discard, children: t("discard") }),
642
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: css.save, disabled: blocked, onClick: () => void save(), children: t(saving ? "saving" : "save") })
716
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: css.footer, children: [
717
+ failed ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: css.failed, role: "status", children: t("saveFailed") }) : null,
718
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: css.discard, disabled: !dirty || saving, onClick: discard, children: t("discard") }),
719
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: css.save, disabled: blocked, onClick: () => void save(), children: t(saving ? "saving" : "save") })
643
720
  ] })
644
721
  ] }) : null
645
722
  ] });
646
723
  }
647
- function FieldHead(props) {
648
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.head, children: [
649
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { className: css.label, htmlFor: props.id, children: props.label }),
650
- props.overridden ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: css.badges, children: [
651
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: css.badge, children: props.overriddenLabel }),
652
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: css.reset, disabled: props.disabled, onClick: props.onReset, children: props.resetLabel })
653
- ] }) : null
654
- ] });
724
+
725
+ // src/client/NamespaceCard.tsx
726
+ var import_react2 = require("react");
727
+ var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
728
+ var import_jsx_runtime3 = require("react/jsx-runtime");
729
+ function namespaceCard(spec) {
730
+ return function SpecBoundNamespaceCard(props) {
731
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(NamespaceCard, { ...props, spec });
732
+ };
655
733
  }
656
- function SelectField(props) {
657
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.field, children: [
658
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldHead, { ...props }),
659
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
660
- "select",
734
+ function isOverridden2(snap, field) {
735
+ const user = snap.user;
736
+ if (user === void 0 || user === null || typeof user !== "object") return false;
737
+ return Object.prototype.hasOwnProperty.call(user, field);
738
+ }
739
+ var MODEL_CATALOG_TIMEOUT_MS = 15e3;
740
+ function NamespaceCard(props) {
741
+ const snap = props.useNs((s) => s);
742
+ const t = props.t;
743
+ const spec = props.spec;
744
+ const [open, setOpen] = (0, import_react2.useState)(false);
745
+ const canLoadCatalog = typeof props.loadCatalog === "function";
746
+ const catalogStartedRef = (0, import_react2.useRef)(false);
747
+ const [catalog, setCatalog] = (0, import_react2.useState)(void 0);
748
+ const [catalogStatus, setCatalogStatus] = (0, import_react2.useState)("idle");
749
+ (0, import_react2.useEffect)(() => {
750
+ if (!open || !canLoadCatalog || catalogStartedRef.current) return;
751
+ catalogStartedRef.current = true;
752
+ setCatalogStatus("loading");
753
+ const load = props.loadCatalog;
754
+ void (async () => {
755
+ try {
756
+ const view = await Promise.race([
757
+ load(),
758
+ new Promise((_resolve, reject) => {
759
+ setTimeout(() => reject(new Error("model catalog timed out")), MODEL_CATALOG_TIMEOUT_MS);
760
+ })
761
+ ]);
762
+ setCatalog(view);
763
+ setCatalogStatus("ready");
764
+ } catch {
765
+ setCatalogStatus("failed");
766
+ }
767
+ })();
768
+ }, [open, canLoadCatalog]);
769
+ const committed = snap.value ?? {};
770
+ const [draft, setDraft] = (0, import_react2.useState)({ ...committed });
771
+ const [saving, setSaving] = (0, import_react2.useState)(false);
772
+ const [failed, setFailed] = (0, import_react2.useState)(false);
773
+ (0, import_react2.useEffect)(() => {
774
+ setDraft({ ...committed });
775
+ setFailed(false);
776
+ }, [committed]);
777
+ const edit = (field, value) => {
778
+ setFailed(false);
779
+ setDraft((prev) => ({ ...prev, [field]: value }));
780
+ };
781
+ const numericInvalid = (field) => {
782
+ if (field.kind !== "number") return false;
783
+ const v = draft[field.key];
784
+ if (v === void 0 || v === null || v === "") return false;
785
+ const n = Number(v);
786
+ return !Number.isFinite(n) || n < (field.minValue ?? 0);
787
+ };
788
+ const dirty = JSON.stringify(draft) !== JSON.stringify(committed);
789
+ const invalid = spec.fields.some(numericInvalid);
790
+ const disabled = !snap.writable;
791
+ const blocked = !dirty || invalid || saving;
792
+ if (snap.status !== "ready") return null;
793
+ const save = async () => {
794
+ setSaving(true);
795
+ setFailed(false);
796
+ try {
797
+ const ops = [];
798
+ for (const field of spec.fields) {
799
+ if (draft[field.key] === committed[field.key]) continue;
800
+ const value = draft[field.key];
801
+ ops.push(value === void 0 ? props.unset(field.key) : props.set(field.key, value));
802
+ }
803
+ await Promise.all(ops);
804
+ } catch {
805
+ setFailed(true);
806
+ } finally {
807
+ setSaving(false);
808
+ }
809
+ };
810
+ const discard = () => {
811
+ setDraft({ ...committed });
812
+ setFailed(false);
813
+ };
814
+ const renderSelectField = (field, base) => {
815
+ const rawValue = typeof draft[field.key] === "string" ? draft[field.key] : "";
816
+ if (!canLoadCatalog || catalogStatus === "failed") {
817
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
818
+ TextField,
819
+ {
820
+ ...base,
821
+ hint: `${base.hint} ${t("modelCatalogUnavailable")}`,
822
+ value: rawValue,
823
+ onChange: (v) => edit(field.key, v === "" ? void 0 : v)
824
+ }
825
+ );
826
+ }
827
+ if (catalogStatus !== "ready") {
828
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
829
+ SelectField,
830
+ {
831
+ ...base,
832
+ disabled: true,
833
+ value: "",
834
+ options: [{ value: "", label: t("modelCatalogLoading") }],
835
+ onChange: () => {
836
+ }
837
+ }
838
+ );
839
+ }
840
+ const resolved = field.options?.({ catalog, draft }) ?? [];
841
+ if (resolved.length === 0) {
842
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
843
+ TextField,
844
+ {
845
+ ...base,
846
+ hint: `${base.hint} ${t("modelCatalogUnavailable")}`,
847
+ value: rawValue,
848
+ onChange: (v) => edit(field.key, v === "" ? void 0 : v)
849
+ }
850
+ );
851
+ }
852
+ const opts = field.emptyOptionKey === void 0 ? [...resolved] : [{ value: "", label: t(field.emptyOptionKey) }, ...resolved];
853
+ if (rawValue !== "" && !opts.some((o) => o.value === rawValue)) {
854
+ opts.push({ value: rawValue, label: rawValue });
855
+ }
856
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
857
+ SelectField,
661
858
  {
662
- id: props.id,
663
- className: css.select,
664
- value: props.value,
665
- disabled: props.disabled,
666
- onChange: (e) => props.onChange(e.target.value),
667
- children: props.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: o.value, children: o.label }, o.value))
859
+ ...base,
860
+ value: rawValue,
861
+ options: opts,
862
+ onChange: (v) => edit(field.key, v === "" ? void 0 : v)
668
863
  }
669
- ),
670
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: css.hint, children: props.hint })
671
- ] });
672
- }
673
- function NumberField(props) {
674
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.field, children: [
675
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldHead, { ...props }),
676
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
677
- "input",
864
+ );
865
+ };
866
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("li", { className: `${css.card}${open ? ` ${css.cardOpen}` : ""}`, children: [
867
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
868
+ "button",
678
869
  {
679
- id: props.id,
680
- className: props.invalid ? css.inputInvalid : css.input,
681
- type: "text",
682
- inputMode: "numeric",
683
- ...props.invalid ? { "aria-invalid": true } : {},
684
- value: String(props.value),
685
- disabled: props.disabled,
686
- onChange: (e) => props.onChange(e.target.value)
870
+ type: "button",
871
+ className: css.header,
872
+ "aria-expanded": open,
873
+ "aria-label": `${t(open ? "collapse" : "expand")}: ${t(spec.titleKey)}`,
874
+ onClick: () => {
875
+ setOpen(!open);
876
+ },
877
+ children: [
878
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: css.headText, children: [
879
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: css.name, children: t(spec.titleKey) }),
880
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: css.description, children: t(spec.descriptionKey) })
881
+ ] }),
882
+ dirty ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: css.pending, children: t("unsaved") }) : null,
883
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives2.IconChevronDownOutline14, { className: `${css.chevron}${open ? ` ${css.chevronOpen}` : ""}` })
884
+ ]
687
885
  }
688
886
  ),
689
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: props.invalid ? css.invalid : css.hint, children: props.invalid ? props.invalidLabel : props.hint })
690
- ] });
691
- }
692
- function CheckboxField(props) {
693
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.field, children: [
694
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.head, children: [
695
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: css.checkRow, children: [
696
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
697
- "input",
887
+ open ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: css.body, children: [
888
+ !snap.writable ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: css.readOnly, role: "status", children: t("readOnly") }) : null,
889
+ spec.fields.map((field) => {
890
+ const label = t(field.labelKey ?? field.key);
891
+ const hint = t(field.hintKey ?? `${field.key}Hint`);
892
+ const base = {
893
+ key: field.key,
894
+ id: `dsh-settings-${field.key}`,
895
+ label,
896
+ hint,
897
+ overridden: isOverridden2(snap, field.key),
898
+ overriddenLabel: t("overridden"),
899
+ resetLabel: t("reset"),
900
+ disabled,
901
+ onReset: () => {
902
+ void props.unset(field.key);
903
+ edit(field.key, void 0);
904
+ }
905
+ };
906
+ if (field.kind === "checkbox") {
907
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
908
+ CheckboxField,
909
+ {
910
+ ...base,
911
+ checked: Boolean(draft[field.key] ?? false),
912
+ onChange: (v) => edit(field.key, v)
913
+ }
914
+ );
915
+ }
916
+ if (field.kind === "number") {
917
+ const raw = draft[field.key];
918
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
919
+ NumberField,
920
+ {
921
+ ...base,
922
+ invalidLabel: t("invalidNumber"),
923
+ invalid: numericInvalid(field),
924
+ value: typeof raw === "number" ? raw : typeof raw === "string" ? raw : "",
925
+ onChange: (v) => edit(field.key, v === "" ? void 0 : Number(v))
926
+ }
927
+ );
928
+ }
929
+ if (field.kind === "select") {
930
+ return renderSelectField(field, base);
931
+ }
932
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
933
+ TextField,
698
934
  {
699
- id: props.id,
700
- type: "checkbox",
701
- className: css.checkbox,
702
- checked: props.checked,
703
- disabled: props.disabled,
704
- onChange: (e) => props.onChange(e.target.checked)
935
+ ...base,
936
+ value: typeof draft[field.key] === "string" ? draft[field.key] : "",
937
+ onChange: (v) => edit(field.key, v === "" ? void 0 : v)
705
938
  }
706
- ),
707
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { className: css.checkLabel, htmlFor: props.id, children: props.label })
708
- ] }),
709
- props.overridden ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: css.badges, children: [
710
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: css.badge, children: props.overriddenLabel }),
711
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: css.reset, disabled: props.disabled, onClick: props.onReset, children: props.resetLabel })
712
- ] }) : null
713
- ] }),
714
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: css.hint, children: props.hint })
939
+ );
940
+ }),
941
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: css.footer, children: [
942
+ failed ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: css.failed, role: "status", children: t("saveFailed") }) : null,
943
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: css.discard, disabled: !dirty || saving, onClick: discard, children: t("discard") }),
944
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: css.save, disabled: blocked, onClick: () => void save(), children: t(saving ? "saving" : "save") })
945
+ ] })
946
+ ] }) : null
715
947
  ] });
716
948
  }
717
- function TextareaField(props) {
718
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: css.field, children: [
719
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldHead, { ...props }),
720
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
721
- "textarea",
722
- {
723
- id: props.id,
724
- className: css.textarea,
725
- value: props.value,
726
- disabled: props.disabled,
727
- rows: 4,
728
- onChange: (e) => props.onChange(e.target.value)
729
- }
730
- ),
731
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: css.hint, children: props.hint })
732
- ] });
949
+
950
+ // src/client/model-catalog.ts
951
+ var PROVIDER_FIELD = "extractionModelProvider";
952
+ function catalogLabel(name, id) {
953
+ return typeof name === "string" && name.length > 0 && name !== id ? `${name} (${id})` : id;
954
+ }
955
+ function providerOptions({ catalog }) {
956
+ return (catalog?.groups ?? []).filter((g) => typeof g?.id === "string" && g.id.length > 0).map((g) => ({ value: g.id, label: catalogLabel(g.name, g.id) }));
957
+ }
958
+ function modelOptions({ catalog, draft }) {
959
+ const groups = catalog?.groups ?? [];
960
+ const providerId = draft[PROVIDER_FIELD];
961
+ const hasProvider = typeof providerId === "string" && providerId.length > 0;
962
+ const scoped = hasProvider ? groups.filter((g) => g.id === providerId) : groups;
963
+ const seen = /* @__PURE__ */ new Set();
964
+ const options = [];
965
+ for (const g of scoped) {
966
+ for (const m of g.models ?? []) {
967
+ if (typeof m?.id !== "string" || m.id.length === 0 || seen.has(m.id)) continue;
968
+ seen.add(m.id);
969
+ const label = hasProvider ? catalogLabel(m.name, m.id) : `${g.id} \xB7 ${catalogLabel(m.name, m.id)}`;
970
+ options.push({ value: m.id, label });
971
+ }
972
+ }
973
+ return options;
733
974
  }
734
975
 
735
976
  // src/client/locales.ts
736
977
  var en = {
737
978
  // Card chrome (mirrors the PluginCard shell's keys).
738
979
  cardTitle: "Memory",
739
- cardDescription: "Long-term memory: how recalled memory reaches the prompt and when it is extracted.",
980
+ cardDescription: "How recalled memory reaches the prompt, how much the tools return, and how long entries live.",
740
981
  expand: "Show settings",
741
982
  collapse: "Hide settings",
742
983
  unsaved: "Unsaved",
@@ -750,11 +991,46 @@ var en = {
750
991
  invalidNumber: "Enter a number, or leave blank to use the default.",
751
992
  loading: "Loading\u2026",
752
993
  unavailable: "Memory settings are not available on this connection.",
753
- // Fields.
994
+ // Extraction model dropdown states.
995
+ followSessionRoute: "Follow the session model",
996
+ modelCatalogLoading: "Loading model catalog\u2026",
997
+ modelCatalogUnavailable: "Model catalog unavailable \u2014 type the id manually.",
998
+ // Memory card fields (memory namespace).
754
999
  memoryMode: "Memory mode",
755
1000
  memoryModeHint: "How recalled memory is rendered into the system prompt.",
756
1001
  customPolicy: "Custom policy text",
757
1002
  customPolicyHint: 'Used only when memory mode is "custom".',
1003
+ charLimit: "Memory character limit",
1004
+ charLimitHint: "Character budget for the frozen memory content snapshot.",
1005
+ maxSearchResults: "Max search results",
1006
+ maxSearchResultsHint: "Default cap for memory_search / memory_list results; 0 means no limit.",
1007
+ decayDays: "Decay days",
1008
+ decayDaysHint: "Auto-decay project entries not recalled within N days; 0 disables.",
1009
+ // Project notes card (memory namespace).
1010
+ notesCardTitle: "Project Notes",
1011
+ notesCardDescription: "Export conventions and a pitfall log into repo files and inject them into the prompt.",
1012
+ notesEnabled: "Project notes",
1013
+ notesEnabledHint: "Export conventions and the pitfall log into repo files and inject them into the prompt.",
1014
+ notesDir: "Notes directory",
1015
+ notesDirHint: "Repo-relative directory for the generated CONVENTIONS.md / PITFALLS.md.",
1016
+ notesCharLimit: "Notes character limit",
1017
+ notesCharLimitHint: "Character budget for the injected project-notes section.",
1018
+ notesAgentsPointer: "AGENTS.md pointer",
1019
+ notesAgentsPointerHint: "Maintain the managed pointer block in the repo AGENTS.md so other tools discover the notes.",
1020
+ notesMaxEntriesPerFile: "Max entries per notes file",
1021
+ notesMaxEntriesPerFileHint: "Per-file entry cap; the oldest entries are truncated.",
1022
+ // Auto recall card (memory namespace).
1023
+ autoRecallCardTitle: "Auto Recall",
1024
+ autoRecallCardDescription: "Append a per-step recalled-memory block from a store search; the system prompt stays untouched.",
1025
+ autoRecallEnabled: "Auto recall",
1026
+ autoRecallEnabledHint: "On each agent step, search the store for the step's user text and append a fenced recalled-memory message.",
1027
+ autoRecallLimit: "Recall entry limit",
1028
+ autoRecallLimitHint: "Maximum entries in one auto-recall fence; minimum 1.",
1029
+ autoRecallMinChars: "Recall trigger length",
1030
+ autoRecallMinCharsHint: "Skip recall when the step's user text is shorter than this many characters.",
1031
+ // Review extraction card (memory-review namespace).
1032
+ reviewCardTitle: "Automatic Extraction",
1033
+ reviewCardDescription: "When conversations are distilled into durable memory, which model runs it, and how oversized entries get re-summarized.",
758
1034
  reviewEnabled: "Automatic review extraction",
759
1035
  reviewEnabledHint: "Extract durable facts from the conversation automatically.",
760
1036
  reviewThreshold: "Review candidate threshold",
@@ -763,12 +1039,29 @@ var en = {
763
1039
  flushOnCompactionHint: "Write pending memory when the context is compacted.",
764
1040
  flushOnDispose: "Flush on dispose",
765
1041
  flushOnDisposeHint: "Write pending memory when the session ends.",
766
- charLimit: "Memory character limit",
767
- charLimitHint: "Character budget for the frozen memory content snapshot."
1042
+ extractionModelProvider: "Extraction provider",
1043
+ extractionModelProviderHint: "LLM provider for extraction/dedup calls, picked from the configured providers; the default follows the session model.",
1044
+ extractionModelModel: "Extraction model",
1045
+ extractionModelModelHint: "Model for extraction/dedup calls, picked from the chosen provider's catalog; the default follows the session model.",
1046
+ extractionBudget: "Extraction budget",
1047
+ extractionBudgetHint: "Max extraction + judge calls per session; 0 means unlimited.",
1048
+ judgeEnabled: "Dedup judge",
1049
+ judgeEnabledHint: "Run the LLM judge on near-duplicate hits before merging them.",
1050
+ pitfallStreakThreshold: "Pitfall streak threshold",
1051
+ pitfallStreakThresholdHint: "Consecutive same-signature failures \u2014 once resolved \u2014 that log a pitfall entry.",
1052
+ curatorEnabled: "Curator pass",
1053
+ curatorEnabledHint: "Periodically rewrite the longest oversized entries into concise one-liners with the extraction model.",
1054
+ curatorEveryNSessions: "Curator interval (sessions)",
1055
+ curatorEveryNSessionsHint: "Run the curator pass every N session creations; minimum 1.",
1056
+ curatorMaxEntries: "Curator max entries",
1057
+ curatorMaxEntriesHint: "Maximum entries selected per pass, longest first; minimum 1.",
1058
+ curatorMinChars: "Curator minimum length",
1059
+ curatorMinCharsHint: "Only entries at least this long are selected for re-summarization."
768
1060
  };
769
1061
  var zh = {
1062
+ // Card chrome
770
1063
  cardTitle: "\u8BB0\u5FC6",
771
- cardDescription: "\u957F\u671F\u8BB0\u5FC6\uFF1A\u53EC\u56DE\u7684\u8BB0\u5FC6\u5982\u4F55\u8FDB\u5165\u63D0\u793A\u8BCD\u3001\u4EE5\u53CA\u4F55\u65F6\u81EA\u52A8\u63D0\u53D6\u3002",
1064
+ cardDescription: "\u53EC\u56DE\u7684\u8BB0\u5FC6\u5982\u4F55\u8FDB\u5165\u63D0\u793A\u8BCD\u3001\u5DE5\u5177\u8FD4\u56DE\u591A\u5C11\u3001\u8BB0\u5FC6\u4FDD\u7559\u591A\u4E45\u3002",
772
1065
  expand: "\u5C55\u5F00\u8BBE\u7F6E",
773
1066
  collapse: "\u6536\u8D77\u8BBE\u7F6E",
774
1067
  unsaved: "\u672A\u4FDD\u5B58",
@@ -782,10 +1075,46 @@ var zh = {
782
1075
  invalidNumber: "\u8BF7\u586B\u6570\u5B57\uFF1B\u7559\u7A7A\u8868\u793A\u4F7F\u7528\u9ED8\u8BA4\u503C\u3002",
783
1076
  loading: "\u6B63\u5728\u52A0\u8F7D\u2026",
784
1077
  unavailable: "\u5F53\u524D\u8FDE\u63A5\u4E0D\u53EF\u7528\u8BB0\u5FC6\u8BBE\u7F6E\u3002",
1078
+ // 提取模型下拉状态
1079
+ followSessionRoute: "\u8DDF\u968F\u4F1A\u8BDD\u6A21\u578B",
1080
+ modelCatalogLoading: "\u6B63\u5728\u52A0\u8F7D\u6A21\u578B\u76EE\u5F55\u2026",
1081
+ modelCatalogUnavailable: "\u6A21\u578B\u76EE\u5F55\u4E0D\u53EF\u7528\uFF0C\u8BF7\u624B\u52A8\u8F93\u5165 id\u3002",
1082
+ // 记忆卡片字段(memory 命名空间)
785
1083
  memoryMode: "\u8BB0\u5FC6\u6A21\u5F0F",
786
1084
  memoryModeHint: "\u53EC\u56DE\u7684\u8BB0\u5FC6\u5982\u4F55\u6E32\u67D3\u8FDB\u7CFB\u7EDF\u63D0\u793A\u8BCD\u3002",
787
1085
  customPolicy: "\u81EA\u5B9A\u4E49\u7B56\u7565\u6587\u672C",
788
1086
  customPolicyHint: '\u4EC5\u5728\u8BB0\u5FC6\u6A21\u5F0F\u4E3A "custom" \u65F6\u4F7F\u7528\u3002',
1087
+ charLimit: "\u8BB0\u5FC6\u5B57\u7B26\u4E0A\u9650",
1088
+ charLimitHint: "\u51BB\u7ED3\u8BB0\u5FC6\u5185\u5BB9\u5FEB\u7167\u7684\u5B57\u7B26\u9884\u7B97\u3002",
1089
+ maxSearchResults: "\u6700\u5927\u641C\u7D22\u7ED3\u679C\u6570",
1090
+ maxSearchResultsHint: "memory_search / memory_list \u7684\u9ED8\u8BA4\u6761\u6570\u4E0A\u9650\uFF1B0 \u8868\u793A\u4E0D\u9650\u3002",
1091
+ decayDays: "\u8870\u51CF\u5929\u6570",
1092
+ decayDaysHint: "N \u5929\u672A\u53EC\u56DE\u7684 project \u6761\u76EE\u81EA\u52A8\u8870\u51CF\uFF1B0 \u8868\u793A\u7981\u7528\u3002",
1093
+ // 项目笔记卡片(memory 命名空间)
1094
+ notesCardTitle: "\u9879\u76EE\u7B14\u8BB0",
1095
+ notesCardDescription: "\u628A\u7F16\u7801\u7EA6\u5B9A\u4E0E\u8E29\u5751\u65E5\u5FD7\u5BFC\u51FA\u5230\u4ED3\u5E93\u6587\u4EF6\u5E76\u6CE8\u5165\u63D0\u793A\u8BCD\u3002",
1096
+ notesEnabled: "\u9879\u76EE\u7B14\u8BB0",
1097
+ notesEnabledHint: "\u628A\u7F16\u7801\u7EA6\u5B9A\u4E0E\u8E29\u5751\u65E5\u5FD7\u5BFC\u51FA\u5230\u4ED3\u5E93\u6587\u4EF6\uFF0C\u5E76\u6CE8\u5165\u7CFB\u7EDF\u63D0\u793A\u8BCD\u3002",
1098
+ notesDir: "\u7B14\u8BB0\u76EE\u5F55",
1099
+ notesDirHint: "\u4ED3\u5E93\u5185\u751F\u6210 CONVENTIONS.md / PITFALLS.md \u7684\u76F8\u5BF9\u76EE\u5F55\u3002",
1100
+ notesCharLimit: "\u7B14\u8BB0\u5B57\u7B26\u4E0A\u9650",
1101
+ notesCharLimitHint: "\u6CE8\u5165\u7684\u9879\u76EE\u7B14\u8BB0\u6BB5\u843D\u7684\u5B57\u7B26\u9884\u7B97\u3002",
1102
+ notesAgentsPointer: "AGENTS.md \u6307\u9488",
1103
+ notesAgentsPointerHint: "\u5728\u4ED3\u5E93 AGENTS.md \u4E2D\u7EF4\u62A4\u6258\u7BA1\u6307\u9488\u5757\uFF0C\u4F9B\u5176\u4ED6\u5DE5\u5177\u53D1\u73B0\u7B14\u8BB0\u3002",
1104
+ notesMaxEntriesPerFile: "\u5355\u6587\u4EF6\u6700\u5927\u6761\u76EE\u6570",
1105
+ notesMaxEntriesPerFileHint: "\u6BCF\u4E2A\u7B14\u8BB0\u6587\u4EF6\u7684\u6761\u76EE\u4E0A\u9650\uFF0C\u8D85\u51FA\u622A\u65AD\u6700\u65E7\u7684\u6761\u76EE\u3002",
1106
+ // 自动召回卡片(memory 命名空间)
1107
+ autoRecallCardTitle: "\u81EA\u52A8\u53EC\u56DE",
1108
+ autoRecallCardDescription: "\u6BCF\u4E2A\u6B65\u9AA4\u68C0\u7D22\u8BB0\u5FC6\u5E93\u5E76\u8FFD\u52A0\u53EC\u56DE\u5757\uFF0C\u7CFB\u7EDF\u63D0\u793A\u8BCD\u4FDD\u6301\u4E0D\u53D8\u3002",
1109
+ autoRecallEnabled: "\u6B65\u7EA7\u81EA\u52A8\u53EC\u56DE",
1110
+ autoRecallEnabledHint: "\u5728\u6BCF\u4E2A\u6B65\u9AA4\u6309\u7528\u6237\u6587\u672C\u68C0\u7D22\u8BB0\u5FC6\u5E93\uFF0C\u8FFD\u52A0\u4E00\u6BB5\u56F4\u680F\u53EC\u56DE\u6D88\u606F\uFF1B\u4E0D\u6539\u7CFB\u7EDF\u63D0\u793A\u8BCD\uFF0CKV-cache \u524D\u7F00\u7A33\u5B9A\u3002",
1111
+ autoRecallLimit: "\u5355\u6B21\u53EC\u56DE\u6761\u6570\u4E0A\u9650",
1112
+ autoRecallLimitHint: "\u4E00\u6B21\u81EA\u52A8\u53EC\u56DE\u6700\u591A\u9644\u5E26\u7684\u6761\u76EE\u6570\uFF0C\u6700\u5C0F\u4E3A 1\u3002",
1113
+ autoRecallMinChars: "\u89E6\u53D1\u6700\u5C0F\u6587\u672C\u957F\u5EA6",
1114
+ autoRecallMinCharsHint: "\u6B65\u9AA4\u7528\u6237\u6587\u672C\u77ED\u4E8E\u8BE5\u5B57\u7B26\u6570\u65F6\u8DF3\u8FC7\u53EC\u56DE\u3002",
1115
+ // 自动提取卡片(memory-review 命名空间)
1116
+ reviewCardTitle: "\u81EA\u52A8\u63D0\u53D6",
1117
+ reviewCardDescription: "\u4F55\u65F6\u628A\u5BF9\u8BDD\u6C89\u6DC0\u4E3A\u957F\u671F\u8BB0\u5FC6\u3001\u4F7F\u7528\u54EA\u4E2A\u6A21\u578B\uFF0C\u4EE5\u53CA\u8D85\u957F\u6761\u76EE\u7684\u5B9A\u671F\u7CBE\u7B80\u3002",
789
1118
  reviewEnabled: "\u81EA\u52A8\u8BC4\u5BA1\u63D0\u53D6",
790
1119
  reviewEnabledHint: "\u81EA\u52A8\u4ECE\u5BF9\u8BDD\u4E2D\u63D0\u53D6\u53EF\u6301\u4E45\u7684\u4E8B\u5B9E\u3002",
791
1120
  reviewThreshold: "\u8BC4\u5BA1\u5019\u9009\u9608\u503C",
@@ -794,29 +1123,131 @@ var zh = {
794
1123
  flushOnCompactionHint: "\u4E0A\u4E0B\u6587\u88AB\u538B\u7F29\u65F6\u5199\u5165\u5F85\u5199\u8BB0\u5FC6\u3002",
795
1124
  flushOnDispose: "\u4F1A\u8BDD\u7ED3\u675F\u65F6\u51B2\u5237",
796
1125
  flushOnDisposeHint: "\u4F1A\u8BDD\u7ED3\u675F\u65F6\u5199\u5165\u5F85\u5199\u8BB0\u5FC6\u3002",
797
- charLimit: "\u8BB0\u5FC6\u5B57\u7B26\u4E0A\u9650",
798
- charLimitHint: "\u51BB\u7ED3\u8BB0\u5FC6\u5185\u5BB9\u5FEB\u7167\u7684\u5B57\u7B26\u9884\u7B97\u3002"
1126
+ extractionModelProvider: "\u63D0\u53D6\u6A21\u578B provider",
1127
+ extractionModelProviderHint: "\u63D0\u53D6/\u53BB\u91CD\u8C03\u7528\u4F7F\u7528\u7684 LLM provider\uFF0C\u4ECE\u5DF2\u914D\u7F6E\u7684 provider \u4E2D\u9009\u62E9\uFF1B\u9ED8\u8BA4\u8DDF\u968F\u4F1A\u8BDD\u6A21\u578B\u3002",
1128
+ extractionModelModel: "\u63D0\u53D6\u6A21\u578B",
1129
+ extractionModelModelHint: "\u63D0\u53D6/\u53BB\u91CD\u8C03\u7528\u4F7F\u7528\u7684\u6A21\u578B\uFF0C\u4ECE\u6240\u9009 provider \u7684\u76EE\u5F55\u4E2D\u9009\u62E9\uFF1B\u9ED8\u8BA4\u8DDF\u968F\u4F1A\u8BDD\u6A21\u578B\u3002",
1130
+ extractionBudget: "\u63D0\u53D6\u9884\u7B97",
1131
+ extractionBudgetHint: "\u6BCF\u4F1A\u8BDD\u6700\u5927\u63D0\u53D6 + \u53BB\u91CD\u88C1\u51B3\u8C03\u7528\u6B21\u6570\uFF1B0 \u8868\u793A\u4E0D\u9650\u3002",
1132
+ judgeEnabled: "\u53BB\u91CD\u88C1\u51B3",
1133
+ judgeEnabledHint: "\u5BF9\u8FD1\u4F3C\u91CD\u590D\u547D\u4E2D\u5728\u5408\u5E76\u524D\u8FD0\u884C LLM \u88C1\u51B3\u3002",
1134
+ pitfallStreakThreshold: "\u8E29\u5751\u8FDE\u7EED\u9608\u503C",
1135
+ pitfallStreakThresholdHint: "\u540C\u7B7E\u540D\u8FDE\u7EED\u5931\u8D25\u8FBE\u5230\u8BE5\u6B21\u6570\u4E14\u6700\u7EC8\u89E3\u51B3\uFF0C\u624D\u8BB0\u5F55\u4E00\u6761\u8E29\u5751\u3002",
1136
+ curatorEnabled: "\u7B56\u5C55\u6574\u7406",
1137
+ curatorEnabledHint: "\u4F4E\u9891\u5730\u628A\u6700\u957F\u7684\u8D85\u5C3A\u5BF8\u6761\u76EE\u7528\u63D0\u53D6\u6A21\u578B\u6539\u5199\u6210\u7B80\u6D01\u5355\u884C\u3002",
1138
+ curatorEveryNSessions: "\u7B56\u5C55\u95F4\u9694\uFF08\u4F1A\u8BDD\u6570\uFF09",
1139
+ curatorEveryNSessionsHint: "\u6BCF\u521B\u5EFA N \u4E2A\u4F1A\u8BDD\u8FD0\u884C\u4E00\u6B21\u7B56\u5C55\u6574\u7406\uFF0C\u6700\u5C0F\u4E3A 1\u3002",
1140
+ curatorMaxEntries: "\u5355\u6B21\u6574\u7406\u6761\u6570\u4E0A\u9650",
1141
+ curatorMaxEntriesHint: "\u6BCF\u6B21\u6574\u7406\u6700\u591A\u9009\u4E2D\u7684\u6761\u76EE\u6570\uFF08\u6700\u957F\u4F18\u5148\uFF09\uFF0C\u6700\u5C0F\u4E3A 1\u3002",
1142
+ curatorMinChars: "\u53C2\u4E0E\u6574\u7406\u6700\u5C0F\u957F\u5EA6",
1143
+ curatorMinCharsHint: "\u4EC5\u957F\u5EA6\u4E0D\u4F4E\u4E8E\u8BE5\u5B57\u7B26\u6570\u7684\u6761\u76EE\u4F1A\u88AB\u9009\u4E2D\u6539\u5199\u3002"
799
1144
  };
800
1145
 
801
1146
  // src/client/index.ts
1147
+ var NOTES_SPEC = {
1148
+ titleKey: "notesCardTitle",
1149
+ descriptionKey: "notesCardDescription",
1150
+ fields: [
1151
+ { key: "notesEnabled", kind: "checkbox" },
1152
+ { key: "notesDir", kind: "text" },
1153
+ { key: "notesCharLimit", kind: "number" },
1154
+ { key: "notesAgentsPointer", kind: "checkbox" },
1155
+ { key: "notesMaxEntriesPerFile", kind: "number" }
1156
+ ]
1157
+ };
1158
+ var AUTORECALL_SPEC = {
1159
+ titleKey: "autoRecallCardTitle",
1160
+ descriptionKey: "autoRecallCardDescription",
1161
+ fields: [
1162
+ { key: "autoRecallEnabled", kind: "checkbox" },
1163
+ { key: "autoRecallLimit", kind: "number", minValue: 1 },
1164
+ { key: "autoRecallMinChars", kind: "number", minValue: 1 }
1165
+ ]
1166
+ };
1167
+ var PROVIDER_FIELD2 = "extractionModelProvider";
1168
+ var REVIEW_SPEC = {
1169
+ titleKey: "reviewCardTitle",
1170
+ descriptionKey: "reviewCardDescription",
1171
+ fields: [
1172
+ { key: "reviewEnabled", kind: "checkbox" },
1173
+ { key: "reviewCandidateThreshold", kind: "number", labelKey: "reviewThreshold", hintKey: "reviewThresholdHint", minValue: 1 },
1174
+ { key: "flushOnCompaction", kind: "checkbox" },
1175
+ { key: "flushOnDispose", kind: "checkbox" },
1176
+ {
1177
+ key: PROVIDER_FIELD2,
1178
+ kind: "select",
1179
+ options: providerOptions,
1180
+ emptyOptionKey: "followSessionRoute"
1181
+ },
1182
+ {
1183
+ key: "extractionModelModel",
1184
+ kind: "select",
1185
+ options: modelOptions,
1186
+ emptyOptionKey: "followSessionRoute"
1187
+ },
1188
+ { key: "extractionBudget", kind: "number" },
1189
+ { key: "judgeEnabled", kind: "checkbox" },
1190
+ { key: "pitfallStreakThreshold", kind: "number", minValue: 1 },
1191
+ { key: "curatorEnabled", kind: "checkbox" },
1192
+ { key: "curatorEveryNSessions", kind: "number", minValue: 1 },
1193
+ { key: "curatorMaxEntries", kind: "number", minValue: 1 },
1194
+ { key: "curatorMinChars", kind: "number", minValue: 1 }
1195
+ ]
1196
+ };
802
1197
  var inject2 = ["slots", "locale", "settingsScope"];
803
1198
  var NS = "settings.memory";
804
- var MEMORY_NS = "memory";
1199
+ var CARDS = [
1200
+ { key: "memory" },
1201
+ { key: "memory-notes", namespace: "memory", spec: NOTES_SPEC },
1202
+ { key: "memory-autorecall", namespace: "memory", spec: AUTORECALL_SPEC },
1203
+ { key: "memory-review", spec: REVIEW_SPEC }
1204
+ ];
1205
+ function createCatalogLoader(connection) {
1206
+ const llm = connection?.api?.llm;
1207
+ if (llm === void 0 || typeof llm.models !== "function") return void 0;
1208
+ return async () => {
1209
+ const response = await llm.models({});
1210
+ return response.result.ok ? response.result.value : void 0;
1211
+ };
1212
+ }
805
1213
  function apply(ctx) {
806
1214
  ctx.effect(() => ctx.locale.register(NS, { zh, en }), "dsh-memory: locale dictionaries");
807
- const scope = ctx.settingsScope.bind({ namespace: MEMORY_NS });
808
- const cardInjected = () => ({
809
- hooks: { memory: scope },
810
- set: (field, value) => scope.set(field, value),
811
- unset: (field) => scope.unset(field)
812
- });
1215
+ const loadCatalog = createCatalogLoader(ctx.get("connection"));
813
1216
  ctx.slots.inject("settings.plugin.item", function* () {
814
- yield ctx.slots.register({
815
- name: "settings.plugin.item",
816
- key: "memory",
817
- locale: NS,
818
- inject: cardInjected
819
- }, MemoryPluginCard);
1217
+ for (const card of CARDS) {
1218
+ const ns = card.namespace ?? card.key;
1219
+ const scope = ctx.settingsScope.bind({ namespace: ns });
1220
+ if (card.spec === void 0) {
1221
+ const typed = scope;
1222
+ const injected2 = () => ({
1223
+ hooks: { memory: typed },
1224
+ set: (field, value) => typed.set(field, value),
1225
+ unset: (field) => typed.unset(field)
1226
+ });
1227
+ yield ctx.slots.register({
1228
+ name: "settings.plugin.item",
1229
+ key: card.key,
1230
+ locale: NS,
1231
+ inject: injected2
1232
+ }, MemoryPluginCard);
1233
+ } else {
1234
+ const spec = card.spec;
1235
+ const typed = scope;
1236
+ const withCatalog = loadCatalog !== void 0 && spec.fields.some((f) => f.kind === "select");
1237
+ const injected2 = () => ({
1238
+ hooks: { ns: typed },
1239
+ set: (field, value) => typed.set(field, value),
1240
+ unset: (field) => typed.unset(field),
1241
+ ...withCatalog ? { loadCatalog } : {}
1242
+ });
1243
+ yield ctx.slots.register({
1244
+ name: "settings.plugin.item",
1245
+ key: card.key,
1246
+ locale: NS,
1247
+ inject: injected2
1248
+ }, namespaceCard(spec));
1249
+ }
1250
+ }
820
1251
  });
821
1252
  }
822
1253