affaan-m/ECC · error · Error

does not accept positional arguments.

Error message

${command} does not accept positional arguments.

What it means

requireNoPositionals enforces that subcommands like init, write, and doctor in scripts/memory.js take only named options, never bare positional arguments. If any positional tokens survive parsing, the command throws '<command> does not accept positional arguments.' This keeps the CLI contract strict and prevents silently ignoring stray arguments.

Solutions

  1. Remove the stray positional and express the intent as an option: `--content` / `--tags` etc.
  2. If you meant to reference a file, check whether an option like --file exists; otherwise pipe the file via stdin (the script reads stdin for write).
  3. Check shell quoting so a single flag value does not split into extra tokens.
  4. Run `node scripts/memory.js --help` to see the accepted subcommand signatures.

Example fix

// before
node scripts/memory.js write note.md --content "x"
// after
echo "x" | node scripts/memory.js write --tags note
Defensive patterns

Strategy: validation

Validate before calling

const COMMANDS_NO_POSITIONALS = new Set(['init','write','doctor']);
const positionals = args.filter(a => !a.startsWith('--') && a !== command);
if (COMMANDS_NO_POSITIONALS.has(command) && positionals.length) throw new Error(`${command} takes no positional args`);

Try / catch

try { run(args); } catch (e) { if (e.message.includes('does not accept positional arguments')) { console.error('Use named options instead of positional arguments'); process.exitCode = 2; } else throw e; }

Prevention

When it happens

Trigger: Running `node scripts/memory.js write somefile.md --content "x"` or `node scripts/memory.js init default` — the bare tokens 'somefile.md'/'default' are positionals.

Common situations: Assuming the script accepts a file path argument like other tools, pasting commands from a different CLI, or an unquoted flag value that got split so part of it became positional.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at scripts/memory.js:135

        skipNext: true,
      };
    }
    if (argument.startsWith('-')) {
      throw new Error(`Unknown option: ${argument}`);
    }
    return { ...state, positionals: [...state.positionals, argument] };
  }, { options: {}, positionals: [], skipNext: false });

  return {
    command,
    options: parsed.options,
    positionals: parsed.positionals,
  };
}

function requireNoPositionals(positionals, command) {
  if (positionals.length > 0) {
    throw new Error(`${command} does not accept positional arguments.`);
  }
}

function oneValue(values, label, fallback = null) {
  if (!values || values.length === 0) return fallback;
  if (values.length > 1) {
    throw new Error(`${label} may be provided only once.`);
  }
  return values[0];
}

function waitForStdinRetry(milliseconds) {
  Atomics.wait(STDIN_RETRY_SIGNAL, 0, 0, milliseconds);
}

function readBoundedStdin(maxBytes, retryOptions = {}) {
  const retryDelayMs = Number.isInteger(retryOptions.retryDelayMs)
    && retryOptions.retryDelayMs > 0

View on GitHub (pinned to 8321021c54)