Skip to content

bug(cli): aiwg remove --provider <name> crashes with TypeError instead of supporting or rejecting the flag #118

@ChronodeAi

Description

@ChronodeAi

TL;DR

aiwg remove all --provider <name> crashes with TypeError: The "path" argument must be of type string. Received an instance of Object before doing any work. Two underlying issues: (1) aiwg remove doesn't recognise the --provider flag at all (silently swallowed by the arg parser), and (2) aiwg remove all treats the literal string all as a plugin id, then explodes downstream when no plugin metadata resolves.

I hit this trying to remove a stale Factory deployment after switching the project from providers: ["factory"] to providers: ["claude"]. There's no documented way to scope aiwg remove to a specific provider, so the natural reach-for-the-flag attempt fails ugly.

Environment (REQUIRED — issues missing any field will be returned for clarification)

  • AIWG version: 2026.5.12 [stable]
  • Operating system: Darwin mac-studio.tail10294f.ts.net 24.6.0 Darwin Kernel Version 24.6.0: Mon Jan 19 22:01:58 PST 2026; root:xnu-11417.140.69.708.3~1/RELEASE_ARM64_T6041 arm64
  • Provider (the AIWG harness you were running): claude-code
  • Node version: v26.0.0
  • Install location: npm-global

Steps to reproduce

# Starting state: aiwg.config has providers:["factory"] from an earlier install,
# you've since switched to claude and want to drop the factory deployment record.
aiwg remove all --provider factory

Expected behavior

One of:

  1. Best: aiwg remove accepts --provider <name> and removes only the artifacts deployed to that provider, plus the deployedTo.<provider> block from aiwg.config.
  2. Acceptable: clear error like Error: unknown flag --provider; remove takes <plugin-id> [--force] [--keep-data] [--dry-run] so the user knows to pick another path.
  3. Acceptable: aiwg remove all errors clearly with Error: plugin id "all" not found; aiwg remove operates on a single plugin id rather than crashing inside path.

Actual behavior

$ aiwg remove all --provider factory
Error: The "path" argument must be of type string. Received an instance of Object

Exit code is non-zero, but no other context (no stack with --verbose, no hint about the flag being unknown).

Suggested fix

The arg parser at tools/plugin/plugin-uninstaller-cli.mjs lines 40–58 only recognises --force, --keep-data, --dry-run. Any other flag (including --provider) is silently dropped and the next positional becomes pluginId. Two changes:

  1. Reject unknown flags in the parser:
    } else if (arg.startsWith('-')) {
      console.error(`Error: unknown flag ${arg}`);
      console.error(`Usage: aiwg remove <plugin-id> [--force] [--keep-data] [--dry-run]`);
      process.exit(2);
    }
  2. Validate the plugin id before path operations. The TypeError originates downstream in dist/src/plugin/plugin-uninstaller.js when pluginId="all" doesn't resolve and something is passed to a path.* call as undefined/Object. Guard with a "plugin id 'X' not found in registry" check before the path resolution.

Optional but valuable:

  1. Add --provider <name> as a real, documented flag — the use case (scoping removal to a single provider when the project is multi-provider) is legitimate and there's no other way to do it today. The workaround is manual: delete the deployed files, then hand-edit ~/.aiwg/aiwg.config to drop deployedTo.<provider>.

Acceptance criteria

  • aiwg remove all --provider factory either works (option 1 above) or fails with a clear error naming the unknown flag — no TypeError, no path-argument crash.
  • aiwg remove all (with no flag) errors with "plugin id 'all' not found" or equivalent — not a TypeError.
  • Regression test added for unknown-flag handling and unknown-plugin-id handling in plugin-uninstaller-cli.mjs.
  • If --provider is implemented, documented in aiwg remove --help.

Related

  • Issues: (no duplicates found via gh issue list -R jmagly/aiwg --search "remove provider" or "TypeError path argument")
  • PRs:
  • Tracker source: filed directly (not imported)

Context

Workaround for users hitting this: manually delete the AIWG-deployed artifacts under the unwanted provider's directory (look for files with aiwg:managed frontmatter marker), then hand-edit ~/.aiwg/aiwg.config to remove installed.<bundle>.deployedTo.<provider>. That's what I did to clean up 229 AIWG-managed files from ~/.factory/{droids,rules} after switching to Claude Code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions