Skip to content

Commit e29ffa0

Browse files
fix: use cross-platform default debates directory
- Default to ~/.bl-debater/debates (works on Linux/macOS/Windows) - Check ./debates first if it exists (project-specific) - Support BL_DEBATER_DIR environment variable override - Auto-create debates directory if it doesn't exist - Document storage locations in AGENT_GUIDE.md
1 parent 23c5bee commit e29ffa0

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

docs/AGENT_GUIDE.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ This guide explains how AI agents (Claude Code, Codex, or any CLI-based LLM) sho
66

77
bl-debater is a CLI tool that coordinates turn-based debates between two AI agents. You communicate by reading and writing to a shared markdown file. The tool manages turn-taking through markers.
88

9+
## Debate Storage
10+
11+
Debates are stored as markdown files. The default location is determined by:
12+
13+
1. **`BL_DEBATER_DIR` environment variable** (if set)
14+
2. **`./debates`** in current directory (if it exists)
15+
3. **`~/.bl-debater/debates`** (default, cross-platform)
16+
17+
The `~/.bl-debater/debates` path works on Linux, macOS, and Windows.
18+
19+
Override with `--debates-dir`:
20+
```bash
21+
bl-debater --debates-dir /path/to/debates start my-debate -p "..." --as role1 --vs role2
22+
```
23+
924
## Getting Started
1025

1126
### If you're starting a debate

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "bl-agent-debater"
7-
version = "0.2.0"
7+
version = "0.2.1"
88
description = "CLI for orchestrating structured debates between AI agents"
99
readme = "README.md"
1010
license = {text = "MIT"}

src/bl_debater/cli.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,36 @@
1515
"""
1616

1717
import argparse
18+
import os
1819
import sys
1920
from pathlib import Path
2021

2122
from .debate import DebateManager, load_role_definition, get_roles_dirs_for_creation
2223
from .formatting import print_error, print_success, print_info, print_header, print_warning
2324

2425

26+
def _get_default_debates_dir() -> Path:
27+
"""Get the default debates directory (cross-platform).
28+
29+
Priority:
30+
1. BL_DEBATER_DIR environment variable
31+
2. ./debates (if exists in current directory)
32+
3. ~/.bl-debater/debates (default, works on Linux/macOS/Windows)
33+
"""
34+
# Check environment variable first
35+
env_dir = os.environ.get("BL_DEBATER_DIR")
36+
if env_dir:
37+
return Path(env_dir)
38+
39+
# Check if ./debates exists in current directory (project-specific)
40+
cwd_debates = Path.cwd() / "debates"
41+
if cwd_debates.exists():
42+
return cwd_debates
43+
44+
# Default to ~/.bl-debater/debates (cross-platform home directory)
45+
return Path.home() / ".bl-debater" / "debates"
46+
47+
2548
def _validate_role(role: str) -> bool:
2649
"""Check if a role definition exists. Returns True if valid."""
2750
return load_role_definition(role) is not None
@@ -382,8 +405,8 @@ def main():
382405
parser.add_argument(
383406
"--debates-dir",
384407
type=Path,
385-
default=Path.cwd() / "debates",
386-
help="Directory for debate files (default: ./debates)"
408+
default=None, # Will use _get_default_debates_dir() if not specified
409+
help="Directory for debate files (default: ~/.bl-debater/debates or ./debates if exists)"
387410
)
388411

389412
subparsers = parser.add_subparsers(dest="command", required=True)
@@ -452,6 +475,14 @@ def main():
452475
export_parser.set_defaults(func=cmd_export)
453476

454477
args = parser.parse_args()
478+
479+
# Resolve default debates directory if not specified
480+
if args.debates_dir is None:
481+
args.debates_dir = _get_default_debates_dir()
482+
483+
# Ensure debates directory exists
484+
args.debates_dir.mkdir(parents=True, exist_ok=True)
485+
455486
args.func(args)
456487

457488
if __name__ == "__main__":

0 commit comments

Comments
 (0)