Skip to content

Commit 76629e8

Browse files
committed
fix(cli): vibe-trading init writes to ~/.vibe-trading/.env
Help text and docstring promised ~/.vibe-trading/.env but the implementation wrote to <AGENT_DIR>/.env, which lives inside site-packages for pip-installed users and gets wiped on upgrade. Align the implementation with the documented behavior, mkdir -p the parent, and chmod 600 the file since it holds API keys.
1 parent 7ef726f commit 76629e8

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

agent/cli.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ def _show_settings() -> None:
12811281
console.print(panel)
12821282
else:
12831283
console.print(Columns(panels, expand=True, equal=True))
1284-
console.print("[dim]Edit configuration in agent/.env, or run vibe-trading init.[/dim]")
1284+
console.print("[dim]Edit configuration in ~/.vibe-trading/.env, or run vibe-trading init.[/dim]")
12851285

12861286

12871287
def _handle_slash_command(input_str: str, *, max_iter: int) -> None:
@@ -2372,7 +2372,7 @@ def _handle_prompt_command(
23722372
return cmd_run(resolved_prompt, max_iter, json_mode=json_mode, no_rich=no_rich)
23732373

23742374

2375-
_INIT_ENV_PATH = AGENT_DIR / ".env"
2375+
_INIT_ENV_PATH = Path.home() / ".vibe-trading" / ".env"
23762376

23772377
_PROVIDER_CHOICES: list[dict[str, str | None]] = [
23782378
{
@@ -2695,7 +2695,7 @@ def cmd_memory_forget(name: str, *, yes: bool = False, memory_dir: Optional[Path
26952695

26962696

26972697
def cmd_init() -> int:
2698-
"""Interactive setup: create agent/.env."""
2698+
"""Interactive setup: create ~/.vibe-trading/.env."""
26992699
console.print(Panel("[bold cyan]Vibe-Trading setup[/bold cyan]\n[dim]Configure the default LLM provider and data tokens.[/dim]", border_style="cyan"))
27002700

27012701
if _INIT_ENV_PATH.exists():
@@ -2778,7 +2778,12 @@ def cmd_init() -> int:
27782778
if tushare_token:
27792779
env_values["TUSHARE_TOKEN"] = tushare_token
27802780

2781+
_INIT_ENV_PATH.parent.mkdir(parents=True, exist_ok=True)
27812782
_INIT_ENV_PATH.write_text(_render_env_content(env_values), encoding="utf-8")
2783+
try:
2784+
_INIT_ENV_PATH.chmod(0o600)
2785+
except OSError:
2786+
pass
27822787

27832788
next_steps = Table.grid(expand=True)
27842789
next_steps.add_column(width=10, style="dim")

0 commit comments

Comments
 (0)