{"record":{"id":"8edad471abf2ce44","repo":"affaan-m/ECC","slug":"unknown-memory-command-command","errorCode":null,"errorMessage":"Unknown memory command: ${command}","messagePattern":"Unknown memory command: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/memory.js","lineNumber":478,"sourceCode":"  read: runReadCommand,\n  save: runWriteCommand,\n  search: runSearchCommand,\n});\n\nfunction runCommand(parsed) {\n  const { command, options, positionals } = parsed;\n  if (options.help || command === 'help') {\n    process.stdout.write(usage());\n    return;\n  }\n  if (['init', 'save', 'handoff'].includes(command)) {\n    assertMutationAllowed(command);\n  }\n  const roots = resolveVaultRoots();\n  const handler = Object.hasOwn(COMMAND_HANDLERS, command)\n    ? COMMAND_HANDLERS[command]\n    : null;\n  if (!handler) throw new Error(`Unknown memory command: ${command}`);\n  return handler({ command, options, positionals, roots });\n}\n\nfunction main(argv = process.argv.slice(2)) {\n  try {\n    runCommand(parseArgs(argv));\n  } catch (error) {\n    process.stderr.write(`Error: ${sanitizeTerminalText(error.message)}\\n`);\n    process.exitCode = 1;\n  }\n}\n\nif (require.main === module) {\n  main();\n}\n\nmodule.exports = {\n  main,","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/memory.js#L460-L496","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check available commands (e.g. `node scripts/memory.js --help`) and use an exact registered subcommand name.","Fix the typo or update the script/docs to the current command name.","Verify argument ordering so no flag swallows the command word: put the subcommand first (`memory save ...`).","If the command genuinely needs to exist, add a handler entry to COMMAND_HANDLERS and dispatch through runCommand."],"exampleFix":"// before\nnode scripts/memory.js show mem_001\n// after\nnode scripts/memory.js read mem_001","handlingStrategy":"validation","validationCode":"const KNOWN = ['init', 'save', 'handoff', 'read', 'list'];\nif (!KNOWN.includes(argv[0])) {\n  throw new Error(`Unknown memory command '${argv[0]}'. Known: ${KNOWN.join(', ')}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  runCommand(parsed);\n} catch (err) {\n  if (String(err.message).startsWith('Unknown memory command:')) {\n    console.error(`${err.message} — run memory --help for the command list.`);\n    process.exitCode = 64;\n  } else throw err;\n}","preventionTips":["Run --help or inspect COMMAND_HANDLERS keys when unsure of a subcommand.","Always place the subcommand as the first token: memory <cmd> [flags].","Update scripts/docs together when commands are renamed to avoid stale invocations."],"tags":["cli","command-not-found","dispatch"],"backgroundTag":"command-not-found","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}