stackmem 1.0.18 → 1.0.20
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/dist/cli.js +19 -4
- package/package.json +1 -1
- package/src/cli.ts +22 -4
package/dist/cli.js
CHANGED
|
@@ -459,6 +459,9 @@ async function cmdCompress(project) {
|
|
|
459
459
|
}
|
|
460
460
|
// --- cm fix --------------------------------------------------------------
|
|
461
461
|
async function cmdFix(project, problem, solution) {
|
|
462
|
+
if (problem.trim().length === 0 || solution.trim().length === 0) {
|
|
463
|
+
fail("Problem and solution cannot be empty.");
|
|
464
|
+
}
|
|
462
465
|
const { error } = await supabase
|
|
463
466
|
.from("execution_log")
|
|
464
467
|
.insert({ project, problem, solution, resolved: false, device_id: getDeviceId() });
|
|
@@ -522,13 +525,18 @@ async function cmdSearch(project, query) {
|
|
|
522
525
|
}
|
|
523
526
|
// --- cm resolve ------------------------------------------------------------
|
|
524
527
|
async function cmdResolve(project, memoryId) {
|
|
525
|
-
const { error } = await supabase
|
|
528
|
+
const { data, error } = await supabase
|
|
526
529
|
.from("memories")
|
|
527
530
|
.update({ resolved: true })
|
|
528
531
|
.eq("project", project)
|
|
529
|
-
.eq("id", memoryId)
|
|
532
|
+
.eq("id", memoryId)
|
|
533
|
+
.select("id");
|
|
530
534
|
if (error)
|
|
531
535
|
fail(`Failed to resolve memory: ${error.message}`);
|
|
536
|
+
if (!data || data.length === 0) {
|
|
537
|
+
console.log(`No memory found with ID [${memoryId}]`);
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
532
540
|
console.log(`Resolved memory [${memoryId}]`);
|
|
533
541
|
}
|
|
534
542
|
// --- cm delete -------------------------------------------------------------
|
|
@@ -539,13 +547,18 @@ async function cmdDelete(project, memoryId) {
|
|
|
539
547
|
.or(`source_id.eq.${memoryId},target_id.eq.${memoryId}`);
|
|
540
548
|
if (linksError)
|
|
541
549
|
fail(`Failed to delete memory links: ${linksError.message}`);
|
|
542
|
-
const { error } = await supabase
|
|
550
|
+
const { data, error } = await supabase
|
|
543
551
|
.from("memories")
|
|
544
552
|
.delete()
|
|
545
553
|
.eq("project", project)
|
|
546
|
-
.eq("id", memoryId)
|
|
554
|
+
.eq("id", memoryId)
|
|
555
|
+
.select("id");
|
|
547
556
|
if (error)
|
|
548
557
|
fail(`Failed to delete memory: ${error.message}`);
|
|
558
|
+
if (!data || data.length === 0) {
|
|
559
|
+
console.log(`No memory found with ID [${memoryId}]`);
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
549
562
|
console.log(`Deleted memory [${memoryId}]`);
|
|
550
563
|
}
|
|
551
564
|
// --- cm inspect ------------------------------------------------------------
|
|
@@ -937,6 +950,8 @@ dist/
|
|
|
937
950
|
.DS_Store
|
|
938
951
|
*.log
|
|
939
952
|
coverage/
|
|
953
|
+
*-memories.json
|
|
954
|
+
*.db
|
|
940
955
|
`;
|
|
941
956
|
// Returns true if the file was created, false if it already existed
|
|
942
957
|
// (and was left untouched).
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -544,6 +544,10 @@ async function cmdCompress(project: string) {
|
|
|
544
544
|
// --- cm fix --------------------------------------------------------------
|
|
545
545
|
|
|
546
546
|
async function cmdFix(project: string, problem: string, solution: string) {
|
|
547
|
+
if (problem.trim().length === 0 || solution.trim().length === 0) {
|
|
548
|
+
fail("Problem and solution cannot be empty.");
|
|
549
|
+
}
|
|
550
|
+
|
|
547
551
|
const { error } = await supabase
|
|
548
552
|
.from("execution_log")
|
|
549
553
|
.insert({ project, problem, solution, resolved: false, device_id: getDeviceId() });
|
|
@@ -617,14 +621,20 @@ async function cmdSearch(project: string, query: string) {
|
|
|
617
621
|
// --- cm resolve ------------------------------------------------------------
|
|
618
622
|
|
|
619
623
|
async function cmdResolve(project: string, memoryId: string) {
|
|
620
|
-
const { error } = await supabase
|
|
624
|
+
const { data, error } = await supabase
|
|
621
625
|
.from("memories")
|
|
622
626
|
.update({ resolved: true })
|
|
623
627
|
.eq("project", project)
|
|
624
|
-
.eq("id", memoryId)
|
|
628
|
+
.eq("id", memoryId)
|
|
629
|
+
.select("id");
|
|
625
630
|
|
|
626
631
|
if (error) fail(`Failed to resolve memory: ${error.message}`);
|
|
627
632
|
|
|
633
|
+
if (!data || data.length === 0) {
|
|
634
|
+
console.log(`No memory found with ID [${memoryId}]`);
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
|
|
628
638
|
console.log(`Resolved memory [${memoryId}]`);
|
|
629
639
|
}
|
|
630
640
|
|
|
@@ -638,14 +648,20 @@ async function cmdDelete(project: string, memoryId: string) {
|
|
|
638
648
|
|
|
639
649
|
if (linksError) fail(`Failed to delete memory links: ${linksError.message}`);
|
|
640
650
|
|
|
641
|
-
const { error } = await supabase
|
|
651
|
+
const { data, error } = await supabase
|
|
642
652
|
.from("memories")
|
|
643
653
|
.delete()
|
|
644
654
|
.eq("project", project)
|
|
645
|
-
.eq("id", memoryId)
|
|
655
|
+
.eq("id", memoryId)
|
|
656
|
+
.select("id");
|
|
646
657
|
|
|
647
658
|
if (error) fail(`Failed to delete memory: ${error.message}`);
|
|
648
659
|
|
|
660
|
+
if (!data || data.length === 0) {
|
|
661
|
+
console.log(`No memory found with ID [${memoryId}]`);
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
|
|
649
665
|
console.log(`Deleted memory [${memoryId}]`);
|
|
650
666
|
}
|
|
651
667
|
|
|
@@ -1066,6 +1082,8 @@ dist/
|
|
|
1066
1082
|
.DS_Store
|
|
1067
1083
|
*.log
|
|
1068
1084
|
coverage/
|
|
1085
|
+
*-memories.json
|
|
1086
|
+
*.db
|
|
1069
1087
|
`;
|
|
1070
1088
|
|
|
1071
1089
|
// Returns true if the file was created, false if it already existed
|