Conversation
There was a problem hiding this comment.
Pull request overview
Refactors Databao CLI command organization by moving Click command definitions into their respective command modules and slimming __main__.py down to CLI wiring/registration, with accompanying architecture documentation updates.
Changes:
- Moved Click decorators/handlers for commands (e.g.,
ask,build,index,init,status,app,mcp) intosrc/databao_cli/commands/*. - Introduced a shared CLI utility helper (
get_project_or_exit) to centralize “find project” handling. - Updated
docs/architecture.mdto document the new CLI command structure and registration approach.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/databao_cli/main.py | Reduced to root Click group + centralized COMMANDS registration wiring. |
| src/databao_cli/commands/_utils.py | Adds shared helper for resolving a project (or exiting). |
| src/databao_cli/commands/status.py | Adds Click command wrapper; switches implementation to use get_project_or_exit. |
| src/databao_cli/commands/init.py | Adds Click command wrapper around existing init implementation and interactive flow. |
| src/databao_cli/commands/build.py | Adds Click command wrapper for build behavior. |
| src/databao_cli/commands/index.py | Adds Click command wrapper for indexing behavior. |
| src/databao_cli/commands/ask.py | Adds Click command wrapper and adjusts ask_impl signature to accept a project path. |
| src/databao_cli/commands/app.py | Adds Click command wrapper; reworks app_impl to accept explicit args/options. |
| src/databao_cli/commands/mcp.py | Adds Click command wrapper for MCP server start. |
| src/databao_cli/commands/datasource/init.py | Introduces datasource group and subcommands (add, check) in-package. |
| docs/architecture.md | Documents new project/CLI structure and command registration mechanism. |
Comments suppressed due to low confidence (2)
src/databao_cli/commands/status.py:34
status_impl()now callsget_project_or_exit(), whichsys.exit(1)s when no Databao project is found. This breaks existing behavior wheredatabao statuscan run outside a project (see tests) and also breaks UI usage (ui/services/dce_operations.get_status_info()imports and callsstatus_impl()), since exiting would terminate the Streamlit process. Consider keepingstatus_impl()non-exiting (usefind_project()and include domain info only when available), and apply the “exit if missing” behavior only in the Click command wrapper if desired.
def status_impl(project_dir: Path) -> str:
project_layout = get_project_or_exit(project_dir)
dce_info = get_databao_context_engine_info()
return _generate_info_string(
dce_info,
[get_databao_context_engine_domain_info(domain) for domain in project_layout.get_domain_dirs()]
if project_layout
else [],
)
docs/architecture.md:66
- This update removes the previously documented “Database Support” details (supported databases / optional deps) from the architecture doc. If that information is still accurate, consider re-adding it here or linking to the new canonical location so users don’t lose guidance on supported backends.
## Extension Points
- Add CLI command: create module in `commands/`, register with Click group
in `__main__.py`.
- Add MCP tool: add handler in `mcp/tools/`, register in `mcp/server.py`.
- Add datasource type: extend via `databao-context-engine` optional deps.
- Add UI page: add to `ui/pages/`.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/databao_cli/commands/status.py:34
status_impl()now callsget_project_or_exit(), which exits with code 1 when run outside a Databao project. This changes the CLI behavior and breaks the existing contract verified bytests/test_status.py(it invokesdatabao statusin an empty temp dir and expects exit_code == 0 with engine/plugin info). Consider usingfind_project(project_dir)here and only adding domain info when a project is found, while still returning system-wide DCE info when no project exists.
def status_impl(project_dir: Path) -> str:
project_layout = get_project_or_exit(project_dir)
dce_info = get_databao_context_engine_info()
return _generate_info_string(
dce_info,
[get_databao_context_engine_domain_info(domain) for domain in project_layout.get_domain_dirs()]
if project_layout
else [],
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/databao_cli/commands/status.py:34
status_impl()now callsget_project_or_exit(), which willsys.exit(1)when run outside a Databao project. This breaksdatabao statusin a non-project directory (see tests expecting exit_code==0) and can also terminate callers likeui/services/dce_operations.get_status_info(). Usefind_project()(allowingNone) instatus_impl, and keep the “no project” behavior as “system-wide info only” rather than exiting; also remove the now-deadif project_layout else []branch onceproject_layoutis optional again.
@click.command()
@click.pass_context
def status(ctx: click.Context) -> None:
"""Display project status and system-wide information."""
click.echo(status_impl(ctx.obj["project_dir"]))
def status_impl(project_dir: Path) -> str:
project_layout = get_project_or_exit(project_dir)
dce_info = get_databao_context_engine_info()
return _generate_info_string(
dce_info,
[get_databao_context_engine_domain_info(domain) for domain in project_layout.get_domain_dirs()]
if project_layout
else [],
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/databao_cli/commands/datasource/check.py:51
fq_datasource_nameis built usingos.pathsep, which is platform-dependent (;on Windows). This output looks like a logical identifier (and tests expectroot:...), so using a fixed separator (e.g.,':') would keep CLI output stable across platforms.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Both test_build and test_index called duckdb.execute() on the shared default in-memory connection instead of the file-scoped connection, causing "table t1 already exists" when both tests ran in the same suite. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Refactor CLI command structure — move command definitions out of main.py into their own modules
__main__.pycontaines the full Click command definitions (decorators, options, arguments, docstrings, and handler bodies) for all CLI commands alongside their business logic. This makes__main__.pya 335-line file that mixes wiring and implementation, making it harder to locate command-specific code.__init__.py__main__.pyshould be reduced to wiring only: the root cli group, and a COMMANDS list