@nandoblanco/opencode-local-memory 1.1.0 → 1.1.1

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 (2) hide show
  1. package/package.json +1 -1
  2. package/tui.ts +381 -258
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nandoblanco/opencode-local-memory",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/tui.ts CHANGED
@@ -716,99 +716,142 @@ function createTuiRenderer() {
716
716
  queueMicrotask(applyDialogWidth);
717
717
  },
718
718
  width: "100%",
719
- height: 28,
719
+ height: 34,
720
720
  flexDirection: "column",
721
721
  backgroundColor: () => theme().background.base,
722
+ paddingLeft: 2,
723
+ paddingRight: 2,
724
+ paddingTop: 1,
725
+ paddingBottom: 1,
726
+ gap: 1,
722
727
  },
723
- // 1. Header Bar
728
+ // 1. Header Bar (single-line, no wrapping)
724
729
  el(
725
730
  "box",
726
731
  {
727
732
  flexDirection: "row",
728
733
  justifyContent: "space-between",
729
734
  alignItems: "center",
730
- paddingX: 2,
731
- paddingTop: 1,
735
+ border: ["bottom"],
736
+ borderColor: () => theme().border.base,
737
+ paddingBottom: 0,
732
738
  flexShrink: 0,
739
+ width: "100%",
733
740
  },
734
741
  el(
735
742
  "box",
736
- { flexDirection: "row", gap: 2, alignItems: "center" },
743
+ { flexDirection: "row", gap: 2, alignItems: "center", flexShrink: 0 },
737
744
  el(
738
745
  "text",
739
746
  {
740
- fg: () => theme().text.base,
747
+ wrapMode: "none",
748
+ flexShrink: 0,
749
+ fg: () => theme().text.action.primary.base,
741
750
  attributes: TextAttributes.BOLD,
742
751
  },
743
- "Local Memory Search"
752
+ "opencode / memory"
744
753
  ),
745
754
  el(
746
755
  "text",
747
- { fg: () => theme().text.muted },
748
- () =>
749
- statusMsg() ||
750
- `${hits().length} of ${allEntries().length} entries`
756
+ {
757
+ wrapMode: "none",
758
+ flexShrink: 0,
759
+ fg: () => theme().text.muted,
760
+ },
761
+ () => props.context.ui.format.path(props.rootDir)
751
762
  )
752
763
  ),
753
764
  el(
754
- "box",
755
- { flexDirection: "row", gap: 2, alignItems: "center" },
756
- el(
757
- "text",
758
- { fg: () => theme().text.muted },
759
- () => props.context.ui.format.path(props.rootDir)
760
- ),
761
- el(
762
- "box",
763
- { paddingX: 1, onMouseUp: () => props.close() },
764
- el("text", { fg: () => theme().text.muted }, "esc")
765
- )
765
+ "text",
766
+ {
767
+ wrapMode: "none",
768
+ flexShrink: 0,
769
+ fg: () => theme().text.muted,
770
+ },
771
+ "[↑↓] select [Tab] pane [^D] delete [Esc] close"
766
772
  )
767
773
  ),
768
774
 
769
- // 2. Search Input + Filter Pills
775
+ // 2. Boxed Filter + Pills Card
770
776
  el(
771
777
  "box",
772
778
  {
773
779
  flexDirection: "column",
774
- paddingX: 2,
775
- paddingY: 1,
776
- gap: 1,
780
+ backgroundColor: () =>
781
+ theme().background.raised?.base ?? theme().background.base,
782
+ border: true,
783
+ borderColor: () =>
784
+ focusPane() === "search"
785
+ ? theme().text.action.primary.base
786
+ : theme().border.base,
787
+ paddingLeft: 2,
788
+ paddingRight: 2,
789
+ paddingTop: 0,
790
+ paddingBottom: 0,
791
+ gap: 0,
777
792
  flexShrink: 0,
778
- border: ["bottom"],
779
- borderColor: () => theme().border.base,
793
+ width: "100%",
780
794
  },
781
795
  el(
782
796
  "box",
783
- { flexDirection: "row", alignItems: "center", gap: 1 },
797
+ {
798
+ flexDirection: "row",
799
+ justifyContent: "space-between",
800
+ alignItems: "center",
801
+ gap: 1,
802
+ width: "100%",
803
+ },
784
804
  el(
785
805
  "text",
786
806
  {
787
- fg: () =>
788
- focusPane() === "search"
789
- ? theme().text.action.primary.base
790
- : theme().text.muted,
807
+ width: 7,
808
+ wrapMode: "none",
809
+ flexShrink: 0,
810
+ fg: () => theme().text.action.primary.base,
791
811
  attributes: TextAttributes.BOLD,
792
812
  },
793
- "›"
813
+ "Filter:"
794
814
  ),
795
- el("input", {
796
- id: "local-memory-search-input",
797
- flexGrow: 1,
798
- value: () => query(),
799
- focused: () => focusPane() === "search",
800
- maxLength: Number.POSITIVE_INFINITY,
801
- placeholder:
802
- "Search local memories (semantic + keyword, or /regex/i)... 0 tokens",
803
- placeholderColor: () => theme().text.muted,
804
- textColor: () => theme().text.base,
805
- focusedTextColor: () => theme().text.formfield.focused,
806
- cursorColor: () => theme().text.formfield.focused,
807
- backgroundColor: () => theme().background.base,
808
- focusedBackgroundColor: () => theme().background.formfield.focused,
809
- onMouseDown: () => setFocusPane("search"),
810
- onInput: (val: string) => setQuery(val),
811
- })
815
+ el(
816
+ "box",
817
+ {
818
+ flexGrow: 1,
819
+ flexShrink: 1,
820
+ minWidth: 0,
821
+ },
822
+ el("input", {
823
+ id: "local-memory-search-input",
824
+ width: "100%",
825
+ value: () => query(),
826
+ focused: () => focusPane() === "search",
827
+ maxLength: Number.POSITIVE_INFINITY,
828
+ placeholder:
829
+ "Search memories (semantic + keyword, topic:name, project:slug, /regex/i)...",
830
+ placeholderColor: () => theme().text.muted,
831
+ textColor: () => theme().text.base,
832
+ focusedTextColor: () => theme().text.formfield.focused,
833
+ cursorColor: () => theme().text.formfield.focused,
834
+ backgroundColor: () =>
835
+ theme().background.raised?.base ?? theme().background.base,
836
+ focusedBackgroundColor: () =>
837
+ theme().background.raised?.base ?? theme().background.base,
838
+ onMouseDown: () => setFocusPane("search"),
839
+ onInput: (val: string) => setQuery(val),
840
+ })
841
+ ),
842
+ el(
843
+ "text",
844
+ {
845
+ wrapMode: "none",
846
+ flexShrink: 0,
847
+ fg: () =>
848
+ theme().text.feedback?.success?.base ??
849
+ theme().text.action.primary.base,
850
+ },
851
+ () =>
852
+ statusMsg() ||
853
+ `${hits().length} of ${allEntries().length} entries · 0 tokens`
854
+ )
812
855
  ),
813
856
  el(
814
857
  "box",
@@ -836,263 +879,343 @@ function createTuiRenderer() {
836
879
  shortcut: "^b",
837
880
  active: () => false,
838
881
  onClick: () => void runImportInDialog(),
882
+ }),
883
+ Pill({
884
+ label: () => "resync",
885
+ shortcut: "^l",
886
+ active: () => false,
887
+ onClick: () => void reloadVectors(true),
839
888
  })
840
889
  )
841
890
  ),
842
891
 
843
- // 3. Split-Pane Body
892
+ // 3. Split-Pane Body: Two Side-by-Side Bordered Cards
844
893
  el(
845
894
  "box",
846
- { flexDirection: "row", flexGrow: 1, minHeight: 0 },
847
- // Left: Results List (44%)
895
+ { flexDirection: "row", gap: 2, flexGrow: 1, minHeight: 0, width: "100%" },
896
+ // Left Card: Results List (44%)
848
897
  el(
849
- "scrollbox",
898
+ "box",
850
899
  {
851
- id: "local-memory-list",
852
- ref: (r: unknown) => {
853
- listScrollRef = r;
854
- },
855
900
  width: "44%",
856
901
  height: "100%",
902
+ flexDirection: "column",
857
903
  flexShrink: 0,
858
- border: ["right"],
904
+ backgroundColor: () =>
905
+ theme().background.raised?.base ?? theme().background.base,
906
+ border: true,
859
907
  borderColor: () =>
860
- focusPane() === "list" ? theme().text.base : theme().border.base,
861
- scrollbarOptions: { visible: false },
908
+ focusPane() === "list"
909
+ ? theme().text.action.primary.base
910
+ : theme().border.base,
911
+ paddingLeft: 1,
912
+ paddingRight: 1,
913
+ paddingTop: 0,
914
+ paddingBottom: 0,
862
915
  onMouseDown: () => setFocusPane("list"),
863
916
  },
864
- createComponent(Show, {
865
- get when() {
866
- return hits().length > 0;
917
+ el(
918
+ "box",
919
+ {
920
+ flexDirection: "row",
921
+ justifyContent: "space-between",
922
+ border: ["bottom"],
923
+ borderColor: () => theme().border.base,
924
+ paddingX: 1,
925
+ flexShrink: 0,
867
926
  },
868
- get fallback() {
869
- return el(
870
- "box",
871
- { paddingX: 2, paddingY: 1 },
872
- el(
873
- "text",
874
- { fg: () => theme().text.muted },
875
- "No matching memory entries found."
876
- )
877
- );
927
+ el(
928
+ "text",
929
+ {
930
+ fg: () => theme().text.action.primary.base,
931
+ attributes: TextAttributes.BOLD,
932
+ },
933
+ "◈ MEMORY ENTRIES"
934
+ ),
935
+ el(
936
+ "text",
937
+ { fg: () => theme().text.muted },
938
+ () => `${mode()} · ${typeFilter()}`
939
+ )
940
+ ),
941
+ el(
942
+ "scrollbox",
943
+ {
944
+ id: "local-memory-list",
945
+ ref: (r: unknown) => {
946
+ listScrollRef = r;
947
+ },
948
+ width: "100%",
949
+ flexGrow: 1,
950
+ minHeight: 0,
951
+ scrollbarOptions: { visible: false },
878
952
  },
879
- get children() {
880
- return createComponent(For, {
881
- get each() {
882
- return hits();
883
- },
884
- children: (item: MemoryHit, idx: () => number) => {
885
- const isSelected = () => selectedIndex() === idx();
886
- return el(
887
- "box",
888
- {
889
- id: () => `memory-row-${idx()}`,
890
- flexDirection: "column",
891
- paddingX: 1,
892
- paddingY: 0,
893
- marginBottom: 1,
894
- flexShrink: 0,
895
- backgroundColor: () =>
896
- isSelected()
897
- ? theme().background.action.primary.focused
898
- : undefined,
899
- onMouseUp: () => setSelectedIndex(idx()),
900
- onMouseOver: () => setSelectedIndex(idx()),
901
- },
902
- el(
953
+ createComponent(Show, {
954
+ get when() {
955
+ return hits().length > 0;
956
+ },
957
+ get fallback() {
958
+ return el(
959
+ "box",
960
+ { paddingX: 1, paddingY: 1 },
961
+ el(
962
+ "text",
963
+ { fg: () => theme().text.muted },
964
+ "No matching memory entries found."
965
+ )
966
+ );
967
+ },
968
+ get children() {
969
+ return createComponent(For, {
970
+ get each() {
971
+ return hits();
972
+ },
973
+ children: (item: MemoryHit, idx: () => number) => {
974
+ const isSelected = () => selectedIndex() === idx();
975
+ return el(
903
976
  "box",
904
977
  {
905
- flexDirection: "row",
906
- justifyContent: "space-between",
907
- width: "100%",
978
+ id: () => `memory-row-${idx()}`,
979
+ flexDirection: "column",
980
+ paddingX: 1,
981
+ paddingY: 0,
982
+ marginBottom: 1,
983
+ flexShrink: 0,
984
+ backgroundColor: () =>
985
+ isSelected()
986
+ ? theme().background.action.primary.focused
987
+ : undefined,
988
+ onMouseUp: () => setSelectedIndex(idx()),
989
+ onMouseOver: () => setSelectedIndex(idx()),
908
990
  },
909
991
  el(
910
- "text",
992
+ "box",
911
993
  {
912
- wrapMode: "none",
913
- fg: () =>
914
- isSelected()
915
- ? theme().text.action.primary.focused
916
- : theme().text.base,
917
- attributes: () =>
918
- isSelected() ? TextAttributes.BOLD : undefined,
994
+ flexDirection: "row",
995
+ justifyContent: "space-between",
996
+ width: "100%",
919
997
  },
920
- () => `${isSelected() ? "› " : " "}[${item.entry.id}]`
998
+ el(
999
+ "text",
1000
+ {
1001
+ wrapMode: "none",
1002
+ truncate: true,
1003
+ fg: () =>
1004
+ isSelected()
1005
+ ? theme().text.action.primary.focused
1006
+ : theme().text.base,
1007
+ attributes: () =>
1008
+ isSelected() ? TextAttributes.BOLD : undefined,
1009
+ },
1010
+ () => `${isSelected() ? "▸ " : " "}[${item.entry.id}]`
1011
+ ),
1012
+ el(
1013
+ "text",
1014
+ {
1015
+ wrapMode: "none",
1016
+ fg: () =>
1017
+ isSelected()
1018
+ ? theme().text.action.primary.focused
1019
+ : theme().text.action.primary.base,
1020
+ },
1021
+ () =>
1022
+ query().trim()
1023
+ ? `${item.score.toFixed(2)} · ${item.entry.file.replace(/\.md$/, "")}`
1024
+ : item.entry.file.replace(/\.md$/, "")
1025
+ )
921
1026
  ),
922
1027
  el(
923
1028
  "text",
924
1029
  {
925
1030
  wrapMode: "none",
1031
+ truncate: true,
926
1032
  fg: () =>
927
1033
  isSelected()
928
1034
  ? theme().text.action.primary.focused
929
1035
  : theme().text.muted,
930
1036
  },
931
- () =>
932
- query().trim()
933
- ? `${item.score.toFixed(2)} · ${item.entry.file.replace(/\.md$/, "")}`
934
- : item.entry.file.replace(/\.md$/, "")
1037
+ () => ` ${item.entry.fact.slice(0, 56)}`
935
1038
  )
936
- ),
937
- el(
938
- "text",
939
- {
940
- wrapMode: "none",
941
- fg: () =>
942
- isSelected()
943
- ? theme().text.action.primary.focused
944
- : theme().text.muted,
945
- },
946
- () => ` ${item.entry.fact.slice(0, 56)}`
947
- )
948
- );
949
- },
950
- });
951
- },
952
- })
1039
+ );
1040
+ },
1041
+ });
1042
+ },
1043
+ })
1044
+ )
953
1045
  ),
954
1046
 
955
- // Right: Full Memory Entry Preview (56%)
1047
+ // Right Card: Full Memory Entry Preview (56%)
956
1048
  el(
957
- "scrollbox",
1049
+ "box",
958
1050
  {
959
- id: "local-memory-preview",
960
- ref: (r: unknown) => {
961
- previewScrollRef = r;
962
- },
963
1051
  flexGrow: 1,
1052
+ height: "100%",
964
1053
  minWidth: 0,
965
1054
  minHeight: 0,
966
- paddingX: 2,
967
- paddingY: 1,
968
- focused: () => focusPane() === "preview",
1055
+ flexDirection: "column",
1056
+ backgroundColor: () =>
1057
+ theme().background.raised?.base ?? theme().background.base,
1058
+ border: true,
1059
+ borderColor: () =>
1060
+ focusPane() === "preview"
1061
+ ? theme().text.action.primary.base
1062
+ : theme().border.base,
1063
+ paddingLeft: 2,
1064
+ paddingRight: 2,
1065
+ paddingTop: 0,
1066
+ paddingBottom: 1,
969
1067
  onMouseDown: () => setFocusPane("preview"),
970
1068
  },
971
- createComponent(Show, {
972
- get when() {
973
- return selectedHit();
1069
+ el(
1070
+ "box",
1071
+ {
1072
+ flexDirection: "row",
1073
+ justifyContent: "space-between",
1074
+ border: ["bottom"],
1075
+ borderColor: () => theme().border.base,
1076
+ marginBottom: 1,
1077
+ flexShrink: 0,
974
1078
  },
975
- get fallback() {
976
- return el(
977
- "text",
978
- { fg: () => theme().text.muted },
979
- "Select a memory entry on the left to inspect it."
980
- );
1079
+ el(
1080
+ "text",
1081
+ {
1082
+ fg: () => theme().text.action.primary.base,
1083
+ attributes: TextAttributes.BOLD,
1084
+ },
1085
+ "◈ ENTRY PREVIEW"
1086
+ ),
1087
+ el(
1088
+ "text",
1089
+ { fg: () => theme().text.muted },
1090
+ () =>
1091
+ selectedHit()
1092
+ ? `${selectedHit()?.entry.file ?? ""} · score ${selectedHit()?.score.toFixed(3) ?? ""}`
1093
+ : "no selection"
1094
+ )
1095
+ ),
1096
+ el(
1097
+ "scrollbox",
1098
+ {
1099
+ id: "local-memory-preview",
1100
+ ref: (r: unknown) => {
1101
+ previewScrollRef = r;
1102
+ },
1103
+ flexGrow: 1,
1104
+ minWidth: 0,
1105
+ minHeight: 0,
1106
+ focused: () => focusPane() === "preview",
981
1107
  },
982
- get children() {
983
- return el(
984
- "box",
985
- { flexDirection: "column", gap: 1 },
986
- el(
987
- "text",
988
- {
989
- fg: () => theme().text.base,
990
- attributes: TextAttributes.BOLD,
991
- },
992
- () => `[${selectedHit()?.entry.id ?? ""}]`
993
- ),
994
- el(
995
- "text",
996
- { fg: () => theme().text.muted, wrapMode: "word" },
997
- () => {
998
- const h = selectedHit();
999
- if (!h) return "";
1000
- const scope = h.entry.project || "global";
1001
- const coreLabel = h.entry.core ? " · Core: pinned" : "";
1002
- return `File: ${h.entry.file} · Date: ${h.entry.date || "N/A"} · Scope: ${scope}${coreLabel} · Score: ${h.score.toFixed(3)}`;
1003
- }
1004
- ),
1005
- el(
1108
+ createComponent(Show, {
1109
+ get when() {
1110
+ return selectedHit();
1111
+ },
1112
+ get fallback() {
1113
+ return el(
1006
1114
  "text",
1007
- { fg: () => theme().text.muted, wrapMode: "word" },
1008
- () => `Tags: [${selectedHit()?.entry.tags ?? ""}]`
1009
- ),
1010
- el(
1115
+ { fg: () => theme().text.muted },
1116
+ "Select a memory entry on the left to inspect it."
1117
+ );
1118
+ },
1119
+ get children() {
1120
+ return el(
1011
1121
  "box",
1012
- {
1013
- flexDirection: "row",
1014
- flexWrap: "wrap",
1015
- marginTop: 1,
1016
- },
1017
- createComponent(For, {
1018
- get each() {
1019
- return splitHighlightedText(
1020
- selectedHit()?.entry.fact ?? "",
1021
- query()
1022
- );
1122
+ { flexDirection: "column", gap: 1 },
1123
+ el(
1124
+ "box",
1125
+ {
1126
+ flexDirection: "column",
1127
+ paddingLeft: 1,
1128
+ border: ["left"],
1129
+ borderColor: () => theme().text.action.primary.base,
1023
1130
  },
1024
- children: (seg: { text: string; match: boolean }) =>
1025
- el(
1026
- "text",
1027
- {
1028
- fg: () =>
1029
- seg.match
1030
- ? theme().text.action.primary.base
1031
- : theme().text.base,
1032
- attributes: () =>
1033
- seg.match ? TextAttributes.BOLD : undefined,
1034
- },
1035
- seg.text
1036
- ),
1037
- })
1038
- ),
1039
- createComponent(Show, {
1040
- get when() {
1041
- return Boolean(selectedSessionBody());
1042
- },
1043
- get children() {
1044
- return el(
1045
- "box",
1131
+ el(
1132
+ "text",
1046
1133
  {
1047
- flexDirection: "column",
1048
- marginTop: 1,
1049
- paddingTop: 1,
1050
- border: ["top"],
1051
- borderColor: () => theme().border.base,
1134
+ fg: () => theme().text.base,
1135
+ attributes: TextAttributes.BOLD,
1052
1136
  },
1053
- el(
1054
- "text",
1137
+ () => `[${selectedHit()?.entry.id ?? ""}]`
1138
+ ),
1139
+ el(
1140
+ "text",
1141
+ { fg: () => theme().text.muted, wrapMode: "word" },
1142
+ () => {
1143
+ const h = selectedHit();
1144
+ if (!h) return "";
1145
+ const scope = h.entry.project || "global";
1146
+ const coreLabel = h.entry.core ? " · Core: pinned" : "";
1147
+ return `File: ${h.entry.file} · Date: ${h.entry.date || "N/A"} · Scope: ${scope}${coreLabel}`;
1148
+ }
1149
+ ),
1150
+ el(
1151
+ "text",
1152
+ { fg: () => theme().text.muted, wrapMode: "word" },
1153
+ () => `Tags: [${selectedHit()?.entry.tags ?? ""}]`
1154
+ )
1155
+ ),
1156
+ el(
1157
+ "box",
1158
+ {
1159
+ flexDirection: "row",
1160
+ flexWrap: "wrap",
1161
+ marginTop: 1,
1162
+ },
1163
+ createComponent(For, {
1164
+ get each() {
1165
+ return splitHighlightedText(
1166
+ selectedHit()?.entry.fact ?? "",
1167
+ query()
1168
+ );
1169
+ },
1170
+ children: (seg: { text: string; match: boolean }) =>
1171
+ el(
1172
+ "text",
1173
+ {
1174
+ fg: () =>
1175
+ seg.match
1176
+ ? theme().text.action.primary.base
1177
+ : theme().text.base,
1178
+ attributes: () =>
1179
+ seg.match ? TextAttributes.BOLD : undefined,
1180
+ },
1181
+ seg.text
1182
+ ),
1183
+ })
1184
+ ),
1185
+ createComponent(Show, {
1186
+ get when() {
1187
+ return Boolean(selectedSessionBody());
1188
+ },
1189
+ get children() {
1190
+ return el(
1191
+ "box",
1055
1192
  {
1056
- fg: () => theme().text.base,
1057
- attributes: TextAttributes.BOLD,
1193
+ flexDirection: "column",
1194
+ marginTop: 1,
1195
+ paddingTop: 1,
1196
+ border: ["top"],
1197
+ borderColor: () => theme().border.base,
1058
1198
  },
1059
- "Full Session Checkpoint Markdown:"
1060
- ),
1061
- el(
1062
- "text",
1063
- { fg: () => theme().text.muted, wrapMode: "word" },
1064
- () => selectedSessionBody()
1065
- )
1066
- );
1067
- },
1068
- })
1069
- );
1070
- },
1071
- })
1072
- )
1073
- ),
1074
-
1075
- // 4. Footer Bar
1076
- el(
1077
- "box",
1078
- {
1079
- flexDirection: "row",
1080
- justifyContent: "space-between",
1081
- paddingX: 2,
1082
- paddingY: 1,
1083
- flexShrink: 0,
1084
- border: ["top"],
1085
- borderColor: () => theme().border.base,
1086
- },
1087
- el(
1088
- "text",
1089
- { fg: () => theme().text.muted },
1090
- "enter select · ↑/↓ or ^n/^k move · ^t type · ^g topic · ^r mode · ^b import · ^l resync · tab pane · esc"
1091
- ),
1092
- el(
1093
- "text",
1094
- { fg: () => theme().text.muted },
1095
- "0 tokens (100% local)"
1199
+ el(
1200
+ "text",
1201
+ {
1202
+ fg: () => theme().text.action.primary.base,
1203
+ attributes: TextAttributes.BOLD,
1204
+ },
1205
+ "◈ FULL SESSION CHECKPOINT MARKDOWN"
1206
+ ),
1207
+ el(
1208
+ "text",
1209
+ { fg: () => theme().text.muted, wrapMode: "word" },
1210
+ () => selectedSessionBody()
1211
+ )
1212
+ );
1213
+ },
1214
+ })
1215
+ );
1216
+ },
1217
+ })
1218
+ )
1096
1219
  )
1097
1220
  )
1098
1221
  );