dbagent-cli 0.1.1__tar.gz → 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/PKG-INFO +1 -1
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/__init__.py +1 -1
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/cli.py +129 -26
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent_cli.egg-info/PKG-INFO +1 -1
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/pyproject.toml +1 -1
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/README.md +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/agent/generator.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/agent/pipeline.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/agent/validator.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/config.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/connectors/base.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/connectors/factory.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/connectors/mongo.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/connectors/relational.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/llm/auto_setup.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/llm/base.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/llm/factory.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/llm/gemini_provider.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/llm/groq_provider.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/llm/mock_provider.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/llm/ollama_provider.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/llm/openrouter_provider.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/schema/formatter.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/schema/models.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/schema/selector.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/ui/console.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent/ui/viewer.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent_cli.egg-info/SOURCES.txt +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent_cli.egg-info/dependency_links.txt +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent_cli.egg-info/entry_points.txt +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent_cli.egg-info/requires.txt +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/dbagent_cli.egg-info/top_level.txt +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/setup.cfg +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/tests/test_cli.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/tests/test_connectors.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/tests/test_generator.py +0 -0
- {dbagent_cli-0.1.1 → dbagent_cli-0.1.3}/tests/test_schema.py +0 -0
|
@@ -14,7 +14,7 @@ from rich.table import Table
|
|
|
14
14
|
from prompt_toolkit import PromptSession
|
|
15
15
|
from prompt_toolkit.history import FileHistory
|
|
16
16
|
|
|
17
|
-
from dbagent import __version__
|
|
17
|
+
from dbagent import __version__, __author__
|
|
18
18
|
from dbagent.config import ConfigManager
|
|
19
19
|
from dbagent.connectors.factory import create_connector
|
|
20
20
|
from dbagent.schema.formatter import SchemaFormatter
|
|
@@ -145,6 +145,86 @@ def _display_pipeline_result(result: PipelineResult, show_sql: bool = True) -> N
|
|
|
145
145
|
print_code(result.sql, "sql", "Generated SQL")
|
|
146
146
|
|
|
147
147
|
|
|
148
|
+
def display_command_guide() -> None:
|
|
149
|
+
"""Display comprehensive command reference table."""
|
|
150
|
+
print_banner()
|
|
151
|
+
console.print("[bold cyan]DB-Agent Command Reference & Guide[/bold cyan]\n")
|
|
152
|
+
|
|
153
|
+
# Table 1: Core Query & Chat
|
|
154
|
+
t1 = Table(title="[bold green]1. Core Query & Interactive Commands[/bold green]", show_header=True, header_style="bold cyan", border_style="dim")
|
|
155
|
+
t1.add_column("Command", style="bold white", width=18)
|
|
156
|
+
t1.add_column("How to Use (Example)", style="cyan", width=42)
|
|
157
|
+
t1.add_column("When to Use", style="dim")
|
|
158
|
+
t1.add_row(
|
|
159
|
+
"ask",
|
|
160
|
+
'db-agent ask "list top 10 users" --db devdb',
|
|
161
|
+
"Ask in natural language -> generates SQL & immediately shows results.",
|
|
162
|
+
)
|
|
163
|
+
t1.add_row(
|
|
164
|
+
"chat",
|
|
165
|
+
"db-agent chat --db devdb",
|
|
166
|
+
"Interactive multi-turn CLI session. Auto-executes reads, remembers schema.",
|
|
167
|
+
)
|
|
168
|
+
t1.add_row(
|
|
169
|
+
"run",
|
|
170
|
+
'db-agent run "SELECT * FROM users" --db devdb',
|
|
171
|
+
"Directly execute raw SQL queries on the database with Rich table output.",
|
|
172
|
+
)
|
|
173
|
+
console.print(t1)
|
|
174
|
+
console.print("")
|
|
175
|
+
|
|
176
|
+
# Table 2: Database Management
|
|
177
|
+
t2 = Table(title="[bold yellow]2. Database & Schema Commands[/bold yellow]", show_header=True, header_style="bold cyan", border_style="dim")
|
|
178
|
+
t2.add_column("Command", style="bold white", width=18)
|
|
179
|
+
t2.add_column("How to Use (Example)", style="cyan", width=42)
|
|
180
|
+
t2.add_column("When to Use", style="dim")
|
|
181
|
+
t2.add_row(
|
|
182
|
+
"connect",
|
|
183
|
+
"db-agent connect <url> --alias prod_db",
|
|
184
|
+
"Test credentials and save connection URL under a friendly alias name (< 0.1s).",
|
|
185
|
+
)
|
|
186
|
+
t2.add_row(
|
|
187
|
+
"scan",
|
|
188
|
+
"db-agent scan --db prod_db --export db.md",
|
|
189
|
+
"Deeply inspect tables, columns, relations, indexes, and export to Markdown/JSON.",
|
|
190
|
+
)
|
|
191
|
+
t2.add_row(
|
|
192
|
+
"profiles",
|
|
193
|
+
"db-agent profiles",
|
|
194
|
+
"List all saved database aliases and their connection URLs.",
|
|
195
|
+
)
|
|
196
|
+
console.print(t2)
|
|
197
|
+
console.print("")
|
|
198
|
+
|
|
199
|
+
# Table 3: AI & Code Generation
|
|
200
|
+
t3 = Table(title="[bold magenta]3. Standalone AI & Generator Commands[/bold magenta]", show_header=True, header_style="bold cyan", border_style="dim")
|
|
201
|
+
t3.add_column("Command", style="bold white", width=18)
|
|
202
|
+
t3.add_column("How to Use (Example)", style="cyan", width=42)
|
|
203
|
+
t3.add_column("When to Use", style="dim")
|
|
204
|
+
t3.add_row(
|
|
205
|
+
"setup",
|
|
206
|
+
"db-agent setup",
|
|
207
|
+
"1-Click offline AI setup. Downloads Ollama & coding model for 100% standalone use.",
|
|
208
|
+
)
|
|
209
|
+
t3.add_row(
|
|
210
|
+
"generate",
|
|
211
|
+
'db-agent generate "create ETL" --db devdb -o etl.py',
|
|
212
|
+
"Generate dialect SQL, Alembic migrations, Python ETL, or APIs to files.",
|
|
213
|
+
)
|
|
214
|
+
t3.add_row(
|
|
215
|
+
"config",
|
|
216
|
+
"db-agent config",
|
|
217
|
+
"Interactive wizard to set default AI provider (Ollama, Gemini, Groq, OpenRouter).",
|
|
218
|
+
)
|
|
219
|
+
t3.add_row(
|
|
220
|
+
"models",
|
|
221
|
+
"db-agent models",
|
|
222
|
+
"Check status (Online/Offline) of local Ollama models and cloud AI providers.",
|
|
223
|
+
)
|
|
224
|
+
console.print(t3)
|
|
225
|
+
console.print("\n[dim]Run [bold]db-agent <command> --help[/bold] for detailed options on any command.[/dim]\n")
|
|
226
|
+
|
|
227
|
+
|
|
148
228
|
# ---------------------------------------------------------------------------
|
|
149
229
|
# CLI Commands
|
|
150
230
|
# ---------------------------------------------------------------------------
|
|
@@ -156,11 +236,16 @@ def main(
|
|
|
156
236
|
):
|
|
157
237
|
"""DB-Agent CLI entry point."""
|
|
158
238
|
if version:
|
|
159
|
-
console.print(f"DB-Agent version [bold cyan]{__version__}[/bold cyan]")
|
|
239
|
+
console.print(f"DB-Agent version [bold cyan]{__version__}[/bold cyan] by [bold]{__author__}[/bold]")
|
|
160
240
|
raise typer.Exit()
|
|
161
241
|
if ctx.invoked_subcommand is None:
|
|
162
|
-
|
|
163
|
-
|
|
242
|
+
display_command_guide()
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
@app.command(name="guide")
|
|
246
|
+
def guide_command():
|
|
247
|
+
"""Display comprehensive command reference, usage examples, and when to use each command."""
|
|
248
|
+
display_command_guide()
|
|
164
249
|
|
|
165
250
|
|
|
166
251
|
# ---- ask (flagship seamless command) ----
|
|
@@ -683,34 +768,52 @@ def models_command():
|
|
|
683
768
|
@app.command(name="setup")
|
|
684
769
|
def setup_command(
|
|
685
770
|
model: str = typer.Option("qwen2.5-coder:1.5b", "--model", "-m", help="Ollama model to install"),
|
|
771
|
+
yes: bool = typer.Option(False, "--yes", "-y", help="Skip confirmation prompt and install local Ollama automatically"),
|
|
686
772
|
):
|
|
687
|
-
"""
|
|
773
|
+
"""Setup wizard: Choose to install standalone local AI (Ollama) or configure cloud AI providers."""
|
|
688
774
|
print_banner()
|
|
689
|
-
console.print("[bold cyan]DB-Agent
|
|
690
|
-
console.print("[dim]This will ensure Ollama is installed, running, and has a local code model ready.[/dim]\n")
|
|
775
|
+
console.print("[bold cyan]DB-Agent AI Engine Setup Wizard[/bold cyan]\n")
|
|
691
776
|
|
|
692
|
-
|
|
777
|
+
install_local = yes
|
|
778
|
+
if not yes:
|
|
779
|
+
console.print("[bold white]DB-Agent supports two ways to run AI:[/bold white]")
|
|
780
|
+
console.print(" 1. [bold green]Local Offline AI (Ollama)[/bold green]: 100% private, zero-cost, runs on your machine without API keys.")
|
|
781
|
+
console.print(" 2. [bold cyan]Free Cloud AI (Gemini / Groq)[/bold cyan]: Lightweight, runs in the cloud via free API keys.\n")
|
|
693
782
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
console.print(f"[dim]{msg}[/dim]")
|
|
703
|
-
else:
|
|
704
|
-
print_info(msg)
|
|
783
|
+
install_local = Confirm.ask(
|
|
784
|
+
"Would you like to install & configure local offline AI (Ollama + Coding Model)?",
|
|
785
|
+
default=True,
|
|
786
|
+
)
|
|
787
|
+
|
|
788
|
+
if install_local:
|
|
789
|
+
console.print("\n[dim]Setting up local offline AI engine...[/dim]\n")
|
|
790
|
+
from dbagent.llm.auto_setup import ensure_ollama_ready
|
|
705
791
|
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
792
|
+
def _log(msg, level="info"):
|
|
793
|
+
if level == "success":
|
|
794
|
+
print_success(msg)
|
|
795
|
+
elif level == "warning":
|
|
796
|
+
print_warning(msg)
|
|
797
|
+
elif level == "error":
|
|
798
|
+
print_error(msg)
|
|
799
|
+
elif level == "progress":
|
|
800
|
+
console.print(f"[dim]{msg}[/dim]")
|
|
801
|
+
else:
|
|
802
|
+
print_info(msg)
|
|
803
|
+
|
|
804
|
+
success, message = ensure_ollama_ready(model=model, print_fn=_log)
|
|
805
|
+
if success:
|
|
806
|
+
config_mgr.set_setting("default_provider", "ollama")
|
|
807
|
+
print_success(message)
|
|
808
|
+
console.print("\n[bold green]You're all set![/bold green] DB-Agent is now configured with local offline AI.\n")
|
|
809
|
+
else:
|
|
810
|
+
print_error(message)
|
|
811
|
+
raise typer.Exit(1)
|
|
711
812
|
else:
|
|
712
|
-
|
|
713
|
-
|
|
813
|
+
print_info("Skipped local Ollama installation.")
|
|
814
|
+
console.print("\n[bold white]Next Steps for Cloud AI:[/bold white]")
|
|
815
|
+
console.print(" * Run [bold cyan]db-agent config[/bold cyan] anytime to configure free Google Gemini or Groq API keys.")
|
|
816
|
+
console.print(" * Or connect directly to your database with [bold cyan]db-agent connect <url> --alias <name>[/bold cyan]\n")
|
|
714
817
|
|
|
715
818
|
|
|
716
819
|
if __name__ == "__main__":
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|