stackmem 1.0.9 → 1.0.10

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 (3) hide show
  1. package/dist/cli.js +32 -16
  2. package/package.json +1 -1
  3. package/src/cli.ts +32 -14
package/dist/cli.js CHANGED
@@ -840,6 +840,14 @@ function writeProjectFile(project, resolvedPath) {
840
840
  // non-interactive). Returns how many memories were actually saved.
841
841
  async function seedMemories(project, resolvedPath) {
842
842
  let seededCount = 0;
843
+ const { data: existingRows, error: existingError } = await supabase
844
+ .from("memories")
845
+ .select("id, content")
846
+ .eq("project", project)
847
+ .eq("resolved", false);
848
+ if (existingError)
849
+ fail(`Failed to load memories: ${existingError.message}`);
850
+ const existingMemories = existingRows ?? [];
843
851
  const packageJsonPath = nodePath.join(resolvedPath, "package.json");
844
852
  if (nodeFs.existsSync(packageJsonPath)) {
845
853
  try {
@@ -849,14 +857,18 @@ async function seedMemories(project, resolvedPath) {
849
857
  ...Object.keys(pkg.devDependencies ?? {}),
850
858
  ];
851
859
  if (depNames.length > 0) {
852
- const { error } = await supabase.from("memories").insert({
853
- project,
854
- type: "discovery",
855
- content: `tech stack: ${depNames.join(", ")}`,
856
- device_id: getDeviceId(),
857
- });
858
- if (!error)
859
- seededCount++;
860
+ const content = `tech stack: ${depNames.join(", ")}`;
861
+ const decision = decideSaveAction(content, existingMemories);
862
+ if (decision.action !== "duplicate") {
863
+ const { error } = await supabase.from("memories").insert({
864
+ project,
865
+ type: "discovery",
866
+ content,
867
+ device_id: getDeviceId(),
868
+ });
869
+ if (!error)
870
+ seededCount++;
871
+ }
860
872
  }
861
873
  }
862
874
  catch {
@@ -871,14 +883,18 @@ async function seedMemories(project, resolvedPath) {
871
883
  .filter((line) => /^[A-Z_]+=/.test(line))
872
884
  .map((line) => line.split("=")[0]);
873
885
  if (varNames.length > 0) {
874
- const { error } = await supabase.from("memories").insert({
875
- project,
876
- type: "constraint",
877
- content: `required env vars: ${varNames.join(", ")}`,
878
- device_id: getDeviceId(),
879
- });
880
- if (!error)
881
- seededCount++;
886
+ const content = `required env vars: ${varNames.join(", ")}`;
887
+ const decision = decideSaveAction(content, existingMemories);
888
+ if (decision.action !== "duplicate") {
889
+ const { error } = await supabase.from("memories").insert({
890
+ project,
891
+ type: "constraint",
892
+ content,
893
+ device_id: getDeviceId(),
894
+ });
895
+ if (!error)
896
+ seededCount++;
897
+ }
882
898
  }
883
899
  }
884
900
  analyzeCodebase(resolvedPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stackmem",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/cli.ts CHANGED
@@ -957,6 +957,16 @@ function writeProjectFile(project: string, resolvedPath: string): void {
957
957
  async function seedMemories(project: string, resolvedPath: string): Promise<number> {
958
958
  let seededCount = 0;
959
959
 
960
+ const { data: existingRows, error: existingError } = await supabase
961
+ .from("memories")
962
+ .select("id, content")
963
+ .eq("project", project)
964
+ .eq("resolved", false);
965
+
966
+ if (existingError) fail(`Failed to load memories: ${existingError.message}`);
967
+
968
+ const existingMemories = existingRows ?? [];
969
+
960
970
  const packageJsonPath = nodePath.join(resolvedPath, "package.json");
961
971
  if (nodeFs.existsSync(packageJsonPath)) {
962
972
  try {
@@ -966,13 +976,17 @@ async function seedMemories(project: string, resolvedPath: string): Promise<numb
966
976
  ...Object.keys(pkg.devDependencies ?? {}),
967
977
  ];
968
978
  if (depNames.length > 0) {
969
- const { error } = await supabase.from("memories").insert({
970
- project,
971
- type: "discovery",
972
- content: `tech stack: ${depNames.join(", ")}`,
973
- device_id: getDeviceId(),
974
- });
975
- if (!error) seededCount++;
979
+ const content = `tech stack: ${depNames.join(", ")}`;
980
+ const decision = decideSaveAction(content, existingMemories);
981
+ if (decision.action !== "duplicate") {
982
+ const { error } = await supabase.from("memories").insert({
983
+ project,
984
+ type: "discovery",
985
+ content,
986
+ device_id: getDeviceId(),
987
+ });
988
+ if (!error) seededCount++;
989
+ }
976
990
  }
977
991
  } catch {
978
992
  // Malformed package.json — skip the tech-stack memory.
@@ -988,13 +1002,17 @@ async function seedMemories(project: string, resolvedPath: string): Promise<numb
988
1002
  .map((line) => line.split("=")[0]);
989
1003
 
990
1004
  if (varNames.length > 0) {
991
- const { error } = await supabase.from("memories").insert({
992
- project,
993
- type: "constraint",
994
- content: `required env vars: ${varNames.join(", ")}`,
995
- device_id: getDeviceId(),
996
- });
997
- if (!error) seededCount++;
1005
+ const content = `required env vars: ${varNames.join(", ")}`;
1006
+ const decision = decideSaveAction(content, existingMemories);
1007
+ if (decision.action !== "duplicate") {
1008
+ const { error } = await supabase.from("memories").insert({
1009
+ project,
1010
+ type: "constraint",
1011
+ content,
1012
+ device_id: getDeviceId(),
1013
+ });
1014
+ if (!error) seededCount++;
1015
+ }
998
1016
  }
999
1017
  }
1000
1018