Skip to content

fix(cli): --importers arg errors, --hubs/--file, status subcommand, empty topology hint - #294

Merged
JordanCoin merged 2 commits into
mainfrom
fix/cli-rough-edges
Nov 6, 2026
Merged

JordanCoin merged 2 commits into
mainfrom
fix/cli-rough-edges

Conversation

@JordanCoin

Copy link
Copy Markdown
Owner

Closes #289.

Four CLI rough edges from exercising every command in 4.7.1. Correction to the issue: --importers <file> from the repo root already worked; the broken cases were the no-value form and running from a subdirectory.

  1. codemap --importers with no value: still exit 2, but prints flag needs an argument: -importers / Run 'codemap --help' for usage. instead of the full flag dump (flag.Usage in main.go, so every flag error gets the one-line hint). From a subdirectory, a relative file now resolves to the enclosing git repo (resolveImportersInvocation), matching absolute paths; -C and an explicit path still win.
  2. --hubs and --file <f> added; MCP handler bodies moved to exported HubsText / FileContextText in mcp/main.go so CLI and MCP share one implementation. mcp/surface_hygiene_test.go counts updated (output still goes through textResult).
  3. codemap status subcommand: version, project root, config path, watch daemon state; reuses ResolveNearestGitRoot, config.ConfigPath, runWatchSubcommand("status"). Listed in --help.
  4. Empty --topology (and MCP get_topology): No modules found: topology reads multi-module manifests (Gradle, Maven, sbt, SwiftPM, Python). For a single-module project use 'codemap --deps'. Names only the registered providers.

Tests: main_cli_rough_edges_test.go, one per fix. go test ./cmd/ . ./mcp/ ./topology/, gofmt -l clean. Left out: --json for --hubs/--file.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FWQw8AjoCA1yjN3T59vk46

…hint

- --importers <relative file> run from a subdirectory now resolves the file
  from the working directory and uses the enclosing repository as the
  project, the same inference an absolute path already got. A flag missing
  its value prints one "Run 'codemap --help'" line instead of the full flag
  dump (still exit 2).
- --hubs and --file <f> print the same text as the MCP get_hubs and
  get_file_context tools: the handlers' bodies moved into exported
  HubsText/FileContextText, which both call.
- codemap status prints version, project root, config path and the watch
  daemon state (reuses runWatchSubcommand "status").
- An empty topology graph names the manifests the registered providers read
  (Gradle, Maven, sbt, SwiftPM, Python) and points single-module projects at
  codemap --deps. The line lives in topology.FormatGraph, so the MCP
  get_topology output gets it too.

Closes #289

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FWQw8AjoCA1yjN3T59vk46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A moderate active issue remains because the new --hubs and --file routes ignore per-invocation scan filters such as --exclude and --max-files, causing incorrect results.

1 open issue
What changed in this PR

This pull request improves several CLI workflows: importer argument handling, hub/file reports, the status subcommand, and guidance for empty topology results. It also shares report rendering between the CLI and MCP interfaces.

Changes:

  • Improves --importers errors and repository-root path resolution.
  • Adds --hubs, --file, and codemap status.
  • Extracts shared hub and file-context renderers for CLI and MCP.
  • Adds actionable empty-topology guidance and regression coverage.
File Summary
topology/​format.go Adds empty-topology guidance. Moderate issue: unmatched ecosystem filters can incorrectly trigger the --deps recommendation.
mcp/​surface_hygiene_test.go Updates handler output-wrapper expectations after renderer extraction.
mcp/​main.go Extracts reusable HubsText and FileContextText renderers.
main.go Adds CLI flags, status handling, importer resolution, and shared report routes. Moderate issues: conflicting --hubs/--file flags perform duplicate graph scans (1 vote), and CLI scan filters are ignored by the new routes (3 votes). Nit: --file errors can incorrectly refer to --importers (1 vote).
main_cli_rough_edges_test.go Adds regression coverage for the CLI rough edges and empty-topology behavior.

This pull request requires changes.

Review effort: Lite

Comment thread main.go Resolved
HubsText and FileContextText always scanned with ConfiguredFilters, so the
CLI's per-invocation filter overrides were ignored. Both now take the
filters; MCP handlers pass ConfiguredFilters, the CLI passes its merged set.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FWQw8AjoCA1yjN3T59vk46
@JordanCoin
JordanCoin merged commit 0b163c9 into main Nov 6, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI rough edges: --importers without path, missing --hubs/--file, codemap status, topology message

2 participants