affaan-m/ECC · error · Error

Unknown memory command

Error message

Unknown memory command: ${command}

What it means

runCommand dispatches parsed CLI invocations through the COMMAND_HANDLERS table. When the command name has no entry (Object.hasOwn check fails), it throws `Unknown memory command: ${command}`. This is the router's guard against misspelled or nonexistent subcommands before any handler runs.

Solutions

  1. Check available commands (e.g. `node scripts/memory.js --help`) and use an exact registered subcommand name.
  2. Fix the typo or update the script/docs to the current command name.
  3. Verify argument ordering so no flag swallows the command word: put the subcommand first (`memory save ...`).
  4. If the command genuinely needs to exist, add a handler entry to COMMAND_HANDLERS and dispatch through runCommand.

Example fix

// before
node scripts/memory.js show mem_001
// after
node scripts/memory.js read mem_001
Defensive patterns

Strategy: validation

Validate before calling

const KNOWN = ['init', 'save', 'handoff', 'read', 'list'];
if (!KNOWN.includes(argv[0])) {
  throw new Error(`Unknown memory command '${argv[0]}'. Known: ${KNOWN.join(', ')}`);
}

Try / catch

try {
  runCommand(parsed);
} catch (err) {
  if (String(err.message).startsWith('Unknown memory command:')) {
    console.error(`${err.message} — run memory --help for the command list.`);
    process.exitCode = 64;
  } else throw err;
}

Prevention

When it happens

Trigger: Calling `node scripts/memory.js <cmd>` where <cmd> is not a registered key in COMMAND_HANDLERS — typos (e.g. `memry`, `show`), removed/renamed subcommands, or a stray first argument such as an accidentally leading flag value.

Common situations: Typo-ing the subcommand; following outdated docs where a command was renamed; a flag consuming the command word (e.g. parser shifting arguments); shell alias expansions injecting unexpected tokens.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/8edad471abf2ce44. Report an issue: GitHub.

Appendix: source

Thrown at scripts/memory.js:478

  read: runReadCommand,
  save: runWriteCommand,
  search: runSearchCommand,
});

function runCommand(parsed) {
  const { command, options, positionals } = parsed;
  if (options.help || command === 'help') {
    process.stdout.write(usage());
    return;
  }
  if (['init', 'save', 'handoff'].includes(command)) {
    assertMutationAllowed(command);
  }
  const roots = resolveVaultRoots();
  const handler = Object.hasOwn(COMMAND_HANDLERS, command)
    ? COMMAND_HANDLERS[command]
    : null;
  if (!handler) throw new Error(`Unknown memory command: ${command}`);
  return handler({ command, options, positionals, roots });
}

function main(argv = process.argv.slice(2)) {
  try {
    runCommand(parseArgs(argv));
  } catch (error) {
    process.stderr.write(`Error: ${sanitizeTerminalText(error.message)}\n`);
    process.exitCode = 1;
  }
}

if (require.main === module) {
  main();
}

module.exports = {
  main,

View on GitHub (pinned to 8321021c54)