{"record":{"id":"6628302bdd0fb7b4","repo":"nanocoai/nanoclaw","slug":"unknown-command","errorCode":"unknown-command","errorMessage":"unknownCommandMessage(req.command)","messagePattern":"unknownCommandMessage\\(req\\.command\\)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/dispatch.ts","lineNumber":70,"sourceCode":"  // Trimming from the end (longest→shortest) means a multi-segment verb like\n  // \"groups-config-add-mcp-server\" still matches before any shorter prefix.\n  if (!cmd) {\n    let shortened = req.command;\n    let idx: number;\n    while ((idx = shortened.lastIndexOf('-')) > 0) {\n      shortened = shortened.slice(0, idx);\n      const fallback = lookup(shortened);\n      if (fallback) {\n        const tail = req.command.slice(shortened.length + 1); // full remainder = id, dashes intact\n        cmd = fallback;\n        req = { ...req, command: shortened, args: { ...req.args, id: req.args.id ?? tail } };\n        break;\n      }\n    }\n  }\n\n  if (!cmd) {\n    return err(req.id, 'unknown-command', unknownCommandMessage(req.command));\n  }\n\n  // Group-scope mechanics for agent callers (visibility, not policy — the\n  // allow/hold/deny decisions live in the guard decision, cli/guard.ts).\n  if (ctx.caller === 'agent') {\n    const configRow = await getContainerConfig(ctx.agentGroupId);\n    const cliScope = configRow?.cli_scope ?? 'group';\n\n    if (cliScope === 'group') {\n      // Auto-fill agent-group-related args so the agent doesn't need\n      // to pass its own group ID explicitly.\n      const fill: Record<string, unknown> = {\n        agent_group_id: req.args.agent_group_id ?? ctx.agentGroupId,\n        group: req.args.group ?? ctx.agentGroupId,\n      };\n      // Only auto-fill --id for resources where it IS the agent group ID\n      // (groups, destinations). For sessions/members --id is a different key.\n      if (cmd.resource === 'groups' || cmd.resource === 'destinations') {","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/nanocoai/nanoclaw/blob/294ef2aee85218b23ad30eda9dfe10e590b54a8c/src/cli/dispatch.ts#L52-L88","documentation":"The ncl CLI dispatcher received a command string that does not match any registered resource/verb combination. After scanning the command table, `cmd` stayed undefined, so the request is rejected with `unknown-command` and a generated help message suggesting valid commands.","triggerScenarios":"ncl requests like `ncl foo list`, `ncl groups frobnicate`, a typo (`ncl wirings lst`), or a command only registered when a channel/provider skill is installed but not present in this install.","commonSituations":"Typos in scripts; using a command documented on a branch/skill not installed here; version drift after update-nanoclaw removed or renamed a verb; stale shell completion.","solutions":["Run `ncl help` or `ncl <resource> help` to list valid commands in this install","Fix the typo / use the exact verb spelling from help output","If the command should exist, verify the skill that registers it is installed (e.g. the channel/provider skill) and rebuild","Pin ncl usage in scripts to commands verified against the current version's help"],"exampleFix":"// before\nncl wirings lst\n// after\nncl wirings list","handlingStrategy":"validation","validationCode":"const valid = await runNcl('help'); // parse the listed commands once, cache the set\nif (!knownCommands.has(`${resource} ${verb}`)) {\n  console.error('unknown command; run ncl help');\n}","typeGuard":"function isKnownCommand(cmd: string, known: Set<string>): boolean {\n  return known.has(cmd.trim().replace(/\\s+/g, ' '));\n}","tryCatchPattern":"Catch the response and match code === 'unknown-command' to surface unknownCommandMessage() help text to the user instead of a raw error.","preventionTips":["Generate ncl invocations from a checked command list, not free text","After updates, re-run `ncl help` and re-pin script commands","Use `ncl <resource> help` before scripting a new verb"],"tags":["cli","ncl","unknown-command","dispatch"],"backgroundTag":"unknown-cli-command","analyzedSha":"294ef2aee85218b23ad30eda9dfe10e590b54a8c","analyzedAt":"2026-08-28T13:59:10.357Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}