stackmem 1.0.17 → 1.0.19
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 +27 -7
- package/package.json +1 -1
- package/src/cli.ts +30 -7
package/dist/cli.js
CHANGED
|
@@ -353,7 +353,7 @@ async function confirmSupersede(oldId, newContent) {
|
|
|
353
353
|
}
|
|
354
354
|
async function cmdSave(project, type, content, force = false) {
|
|
355
355
|
if (!MEMORY_TYPES.includes(type)) {
|
|
356
|
-
fail(`Invalid type
|
|
356
|
+
fail(`Invalid memory type '${type}'. Valid types: decision, constraint, discovery, rejection.`);
|
|
357
357
|
}
|
|
358
358
|
const { data: existingRows, error: existingError } = await supabase
|
|
359
359
|
.from("memories")
|
|
@@ -522,13 +522,18 @@ async function cmdSearch(project, query) {
|
|
|
522
522
|
}
|
|
523
523
|
// --- cm resolve ------------------------------------------------------------
|
|
524
524
|
async function cmdResolve(project, memoryId) {
|
|
525
|
-
const { error } = await supabase
|
|
525
|
+
const { data, error } = await supabase
|
|
526
526
|
.from("memories")
|
|
527
527
|
.update({ resolved: true })
|
|
528
528
|
.eq("project", project)
|
|
529
|
-
.eq("id", memoryId)
|
|
529
|
+
.eq("id", memoryId)
|
|
530
|
+
.select("id");
|
|
530
531
|
if (error)
|
|
531
532
|
fail(`Failed to resolve memory: ${error.message}`);
|
|
533
|
+
if (!data || data.length === 0) {
|
|
534
|
+
console.log(`No memory found with ID [${memoryId}]`);
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
532
537
|
console.log(`Resolved memory [${memoryId}]`);
|
|
533
538
|
}
|
|
534
539
|
// --- cm delete -------------------------------------------------------------
|
|
@@ -539,13 +544,18 @@ async function cmdDelete(project, memoryId) {
|
|
|
539
544
|
.or(`source_id.eq.${memoryId},target_id.eq.${memoryId}`);
|
|
540
545
|
if (linksError)
|
|
541
546
|
fail(`Failed to delete memory links: ${linksError.message}`);
|
|
542
|
-
const { error } = await supabase
|
|
547
|
+
const { data, error } = await supabase
|
|
543
548
|
.from("memories")
|
|
544
549
|
.delete()
|
|
545
550
|
.eq("project", project)
|
|
546
|
-
.eq("id", memoryId)
|
|
551
|
+
.eq("id", memoryId)
|
|
552
|
+
.select("id");
|
|
547
553
|
if (error)
|
|
548
554
|
fail(`Failed to delete memory: ${error.message}`);
|
|
555
|
+
if (!data || data.length === 0) {
|
|
556
|
+
console.log(`No memory found with ID [${memoryId}]`);
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
549
559
|
console.log(`Deleted memory [${memoryId}]`);
|
|
550
560
|
}
|
|
551
561
|
// --- cm inspect ------------------------------------------------------------
|
|
@@ -1189,7 +1199,7 @@ async function cmdInit(project, targetPath) {
|
|
|
1189
1199
|
const resolvedPath = nodePath.resolve(targetPath);
|
|
1190
1200
|
const gitDir = nodePath.join(resolvedPath, ".git");
|
|
1191
1201
|
if (!nodeFs.existsSync(gitDir)) {
|
|
1192
|
-
console.error(`No git repo found at ${targetPath}
|
|
1202
|
+
console.error(`No git repo found at ${targetPath}. Run 'git init' first, then run 'cm init' again.`);
|
|
1193
1203
|
process.exit(1);
|
|
1194
1204
|
}
|
|
1195
1205
|
const gitignoreCreated = writeGitignore(resolvedPath);
|
|
@@ -1649,7 +1659,14 @@ async function main() {
|
|
|
1649
1659
|
let explicitProject;
|
|
1650
1660
|
let type;
|
|
1651
1661
|
let rest;
|
|
1652
|
-
|
|
1662
|
+
// Exactly two positional args can only mean <type> <content> with the
|
|
1663
|
+
// project omitted — an explicit project would need a third slot for
|
|
1664
|
+
// content, which wouldn't exist. Without this check, a typo'd type
|
|
1665
|
+
// (failing the MEMORY_TYPES.includes test below) used to fall into
|
|
1666
|
+
// the "explicit project" branch instead, shifting content out of
|
|
1667
|
+
// existence and surfacing a generic usage() dump instead of the
|
|
1668
|
+
// targeted invalid-type error.
|
|
1669
|
+
if (positional.length === 2 || MEMORY_TYPES.includes(positional[0])) {
|
|
1653
1670
|
explicitProject = null;
|
|
1654
1671
|
[type, ...rest] = positional;
|
|
1655
1672
|
}
|
|
@@ -1657,6 +1674,9 @@ async function main() {
|
|
|
1657
1674
|
explicitProject = positional[0] ?? null;
|
|
1658
1675
|
[, type, ...rest] = positional;
|
|
1659
1676
|
}
|
|
1677
|
+
if (type !== undefined && !MEMORY_TYPES.includes(type)) {
|
|
1678
|
+
fail(`Invalid memory type '${type}'. Valid types: decision, constraint, discovery, rejection.`);
|
|
1679
|
+
}
|
|
1660
1680
|
if (!type || rest.length === 0)
|
|
1661
1681
|
usage();
|
|
1662
1682
|
const project = requireProject(explicitProject);
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -411,7 +411,7 @@ async function confirmSupersede(oldId: string, newContent: string): Promise<bool
|
|
|
411
411
|
|
|
412
412
|
async function cmdSave(project: string, type: string, content: string, force = false) {
|
|
413
413
|
if (!MEMORY_TYPES.includes(type as MemoryType)) {
|
|
414
|
-
fail(`Invalid type
|
|
414
|
+
fail(`Invalid memory type '${type}'. Valid types: decision, constraint, discovery, rejection.`);
|
|
415
415
|
}
|
|
416
416
|
|
|
417
417
|
|
|
@@ -617,14 +617,20 @@ async function cmdSearch(project: string, query: string) {
|
|
|
617
617
|
// --- cm resolve ------------------------------------------------------------
|
|
618
618
|
|
|
619
619
|
async function cmdResolve(project: string, memoryId: string) {
|
|
620
|
-
const { error } = await supabase
|
|
620
|
+
const { data, error } = await supabase
|
|
621
621
|
.from("memories")
|
|
622
622
|
.update({ resolved: true })
|
|
623
623
|
.eq("project", project)
|
|
624
|
-
.eq("id", memoryId)
|
|
624
|
+
.eq("id", memoryId)
|
|
625
|
+
.select("id");
|
|
625
626
|
|
|
626
627
|
if (error) fail(`Failed to resolve memory: ${error.message}`);
|
|
627
628
|
|
|
629
|
+
if (!data || data.length === 0) {
|
|
630
|
+
console.log(`No memory found with ID [${memoryId}]`);
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
|
|
628
634
|
console.log(`Resolved memory [${memoryId}]`);
|
|
629
635
|
}
|
|
630
636
|
|
|
@@ -638,14 +644,20 @@ async function cmdDelete(project: string, memoryId: string) {
|
|
|
638
644
|
|
|
639
645
|
if (linksError) fail(`Failed to delete memory links: ${linksError.message}`);
|
|
640
646
|
|
|
641
|
-
const { error } = await supabase
|
|
647
|
+
const { data, error } = await supabase
|
|
642
648
|
.from("memories")
|
|
643
649
|
.delete()
|
|
644
650
|
.eq("project", project)
|
|
645
|
-
.eq("id", memoryId)
|
|
651
|
+
.eq("id", memoryId)
|
|
652
|
+
.select("id");
|
|
646
653
|
|
|
647
654
|
if (error) fail(`Failed to delete memory: ${error.message}`);
|
|
648
655
|
|
|
656
|
+
if (!data || data.length === 0) {
|
|
657
|
+
console.log(`No memory found with ID [${memoryId}]`);
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
|
|
649
661
|
console.log(`Deleted memory [${memoryId}]`);
|
|
650
662
|
}
|
|
651
663
|
|
|
@@ -1355,7 +1367,7 @@ async function cmdInit(project: string, targetPath: string) {
|
|
|
1355
1367
|
const gitDir = nodePath.join(resolvedPath, ".git");
|
|
1356
1368
|
|
|
1357
1369
|
if (!nodeFs.existsSync(gitDir)) {
|
|
1358
|
-
console.error(`No git repo found at ${targetPath}
|
|
1370
|
+
console.error(`No git repo found at ${targetPath}. Run 'git init' first, then run 'cm init' again.`);
|
|
1359
1371
|
process.exit(1);
|
|
1360
1372
|
}
|
|
1361
1373
|
|
|
@@ -1885,7 +1897,14 @@ async function main() {
|
|
|
1885
1897
|
let explicitProject: string | null;
|
|
1886
1898
|
let type: string | undefined;
|
|
1887
1899
|
let rest: string[];
|
|
1888
|
-
|
|
1900
|
+
// Exactly two positional args can only mean <type> <content> with the
|
|
1901
|
+
// project omitted — an explicit project would need a third slot for
|
|
1902
|
+
// content, which wouldn't exist. Without this check, a typo'd type
|
|
1903
|
+
// (failing the MEMORY_TYPES.includes test below) used to fall into
|
|
1904
|
+
// the "explicit project" branch instead, shifting content out of
|
|
1905
|
+
// existence and surfacing a generic usage() dump instead of the
|
|
1906
|
+
// targeted invalid-type error.
|
|
1907
|
+
if (positional.length === 2 || MEMORY_TYPES.includes(positional[0] as MemoryType)) {
|
|
1889
1908
|
explicitProject = null;
|
|
1890
1909
|
[type, ...rest] = positional;
|
|
1891
1910
|
} else {
|
|
@@ -1893,6 +1912,10 @@ async function main() {
|
|
|
1893
1912
|
[, type, ...rest] = positional;
|
|
1894
1913
|
}
|
|
1895
1914
|
|
|
1915
|
+
if (type !== undefined && !MEMORY_TYPES.includes(type as MemoryType)) {
|
|
1916
|
+
fail(`Invalid memory type '${type}'. Valid types: decision, constraint, discovery, rejection.`);
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1896
1919
|
if (!type || rest.length === 0) usage();
|
|
1897
1920
|
const project = requireProject(explicitProject);
|
|
1898
1921
|
await cmdSave(project, type, rest.join(" "), force);
|