stackmem 1.0.17 → 1.0.18

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 +13 -3
  2. package/package.json +1 -1
  3. package/src/cli.ts +14 -3
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 "${type}". Must be one of: ${MEMORY_TYPES.join(", ")}`);
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")
@@ -1189,7 +1189,7 @@ async function cmdInit(project, targetPath) {
1189
1189
  const resolvedPath = nodePath.resolve(targetPath);
1190
1190
  const gitDir = nodePath.join(resolvedPath, ".git");
1191
1191
  if (!nodeFs.existsSync(gitDir)) {
1192
- console.error(`No git repo found at ${targetPath}`);
1192
+ console.error(`No git repo found at ${targetPath}. Run 'git init' first, then run 'cm init' again.`);
1193
1193
  process.exit(1);
1194
1194
  }
1195
1195
  const gitignoreCreated = writeGitignore(resolvedPath);
@@ -1649,7 +1649,14 @@ async function main() {
1649
1649
  let explicitProject;
1650
1650
  let type;
1651
1651
  let rest;
1652
- if (MEMORY_TYPES.includes(positional[0])) {
1652
+ // Exactly two positional args can only mean <type> <content> with the
1653
+ // project omitted — an explicit project would need a third slot for
1654
+ // content, which wouldn't exist. Without this check, a typo'd type
1655
+ // (failing the MEMORY_TYPES.includes test below) used to fall into
1656
+ // the "explicit project" branch instead, shifting content out of
1657
+ // existence and surfacing a generic usage() dump instead of the
1658
+ // targeted invalid-type error.
1659
+ if (positional.length === 2 || MEMORY_TYPES.includes(positional[0])) {
1653
1660
  explicitProject = null;
1654
1661
  [type, ...rest] = positional;
1655
1662
  }
@@ -1657,6 +1664,9 @@ async function main() {
1657
1664
  explicitProject = positional[0] ?? null;
1658
1665
  [, type, ...rest] = positional;
1659
1666
  }
1667
+ if (type !== undefined && !MEMORY_TYPES.includes(type)) {
1668
+ fail(`Invalid memory type '${type}'. Valid types: decision, constraint, discovery, rejection.`);
1669
+ }
1660
1670
  if (!type || rest.length === 0)
1661
1671
  usage();
1662
1672
  const project = requireProject(explicitProject);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stackmem",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
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 "${type}". Must be one of: ${MEMORY_TYPES.join(", ")}`);
414
+ fail(`Invalid memory type '${type}'. Valid types: decision, constraint, discovery, rejection.`);
415
415
  }
416
416
 
417
417
 
@@ -1355,7 +1355,7 @@ async function cmdInit(project: string, targetPath: string) {
1355
1355
  const gitDir = nodePath.join(resolvedPath, ".git");
1356
1356
 
1357
1357
  if (!nodeFs.existsSync(gitDir)) {
1358
- console.error(`No git repo found at ${targetPath}`);
1358
+ console.error(`No git repo found at ${targetPath}. Run 'git init' first, then run 'cm init' again.`);
1359
1359
  process.exit(1);
1360
1360
  }
1361
1361
 
@@ -1885,7 +1885,14 @@ async function main() {
1885
1885
  let explicitProject: string | null;
1886
1886
  let type: string | undefined;
1887
1887
  let rest: string[];
1888
- if (MEMORY_TYPES.includes(positional[0] as MemoryType)) {
1888
+ // Exactly two positional args can only mean <type> <content> with the
1889
+ // project omitted — an explicit project would need a third slot for
1890
+ // content, which wouldn't exist. Without this check, a typo'd type
1891
+ // (failing the MEMORY_TYPES.includes test below) used to fall into
1892
+ // the "explicit project" branch instead, shifting content out of
1893
+ // existence and surfacing a generic usage() dump instead of the
1894
+ // targeted invalid-type error.
1895
+ if (positional.length === 2 || MEMORY_TYPES.includes(positional[0] as MemoryType)) {
1889
1896
  explicitProject = null;
1890
1897
  [type, ...rest] = positional;
1891
1898
  } else {
@@ -1893,6 +1900,10 @@ async function main() {
1893
1900
  [, type, ...rest] = positional;
1894
1901
  }
1895
1902
 
1903
+ if (type !== undefined && !MEMORY_TYPES.includes(type as MemoryType)) {
1904
+ fail(`Invalid memory type '${type}'. Valid types: decision, constraint, discovery, rejection.`);
1905
+ }
1906
+
1896
1907
  if (!type || rest.length === 0) usage();
1897
1908
  const project = requireProject(explicitProject);
1898
1909
  await cmdSave(project, type, rest.join(" "), force);