Skip to content

Commit 058f6ab

Browse files
jwesleyeclaude
andcommitted
feat: change session storage to project-local ./.chat-sessions
BREAKING CHANGE: Session storage location changed from ~/agent-conversations to ./.chat-sessions in current working directory. Why This Change: - Context separation - sessions from different projects are now separate - Project-local - sessions stay with the project they belong to - Simpler - no configuration needed, predictable behavior - Team-friendly - sessions can optionally be committed to version control Implementation: - Removed save_location from config (no longer configurable) - Updated SessionManager default to Path.cwd() / ".chat-sessions" - Simplified ChatLoop - no longer reads save_location from config - Removed save_location prompts from config wizard - Updated all documentation (README, CONFIG.md) - Updated all help text and error messages - Fixed tests to no longer expect save_location config Migration: - Old sessions remain in ~/agent-conversations as markdown files - No automatic migration - clean break - Users can manually copy if needed Files Changed: - SessionManager: Now uses ./.chat-sessions by default - ChatConfig: Removed save_location from defaults - config_wizard: Removed save_location prompts - display_manager: Updated auto-save message - chat_loop: Removed save_location config reading - README.md: Updated session location examples - docs/CONFIG.md: Updated paths documentation - Tests: Updated to not expect save_location Examples: Before: ~/agent-conversations/ (global, configured) After: ./.chat-sessions/ (project-local, fixed) All tests passing (318 passed, 13 skipped) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 6a29eab commit 058f6ab

8 files changed

Lines changed: 28 additions & 60 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ A feature-rich, interactive CLI for **AWS Strands** agents with token tracking,
1616
- 🎵 **Harmony Support** - Specialized processing for OpenAI Harmony format (gpt-oss models)
1717
- 📜 **Command History** - Navigate previous queries with ↑↓ arrows (persisted to `~/.chat_history`)
1818
- ✍️ **Multi-line Input** - Type `\\` to enter multi-line mode with Ctrl+D to cancel and ↑ to edit previous lines
19-
- 💾 **Session Management** - Save conversations as clean markdown files in `~/agent-conversations/`
19+
- 💾 **Session Management** - Save conversations as clean markdown files in `./.chat-sessions/` (project-local)
2020
- 📋 **Copy Commands** - Copy responses, queries, code blocks, or entire conversations to clipboard
2121
- 💰 **Token Tracking** - Track tokens and costs per query and session
2222
- 📝 **Prompt Templates** - Reusable prompts from `~/.prompts/`
@@ -311,13 +311,13 @@ You: Now let's add authentication
311311

312312
**View saved conversations:**
313313

314-
Conversations are saved as clean markdown files in `~/agent-conversations/`:
314+
Conversations are saved as clean markdown files in `./.chat-sessions/` (in current directory):
315315
```bash
316-
ls -lh ~/agent-conversations/
316+
ls -lh ./.chat-sessions/
317317
# Shows files like: simple_sally_20251230_110627.md
318318
319319
# View a conversation
320-
cat ~/agent-conversations/simple_sally_20251230_110627.md
320+
cat ./.chat-sessions/simple_sally_20251230_110627.md
321321
```
322322

323323
Each saved session includes an auto-generated summary that enables fast, context-aware resumption without replaying all queries.
@@ -328,7 +328,7 @@ Each saved session includes an auto-generated summary that enables fast, context
328328
chat_loop --list-sessions
329329
```
330330

331-
Sessions are saved to `~/agent-conversations/` by default (configurable).
331+
Sessions are saved to `./.chat-sessions/` in your current working directory, providing context separation between different projects.
332332

333333
### Copy Commands
334334

docs/CONFIG.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ File system locations:
8181
8282
```yaml
8383
paths:
84-
save_location: ~/agent-conversations # Conversation exports
8584
log_location: .logs # Log files
8685
```
8786
87+
**Note:** Conversation sessions are now saved to `./.chat-sessions/` in the current working directory (project-local, not configurable). This provides context separation - sessions from different projects are kept separate.
88+
8889
### Behavior
8990

9091
Runtime behavior:
@@ -271,7 +272,7 @@ sessions:
271272

272273
**Saved session structure:**
273274
```
274-
~/agent-conversations/ # Default location (configurable)
275+
./.chat-sessions/ # Project-local (in current directory)
275276
├── myagent_20250126_143022.json # Machine-readable
276277
├── myagent_20250126_143022.md # Human-readable
277278
└── .index.json # Fast lookup index
@@ -281,11 +282,10 @@ sessions:
281282
```yaml
282283
features:
283284
auto_save: true # Required for session persistence
284-
285-
paths:
286-
save_location: ~/agent-conversations # Where sessions are stored
287285
```
288286

287+
Sessions are saved to `./.chat-sessions/` in your current working directory, providing context separation between different projects.
288+
289289
**Usage:**
290290
```bash
291291
# List all saved sessions
@@ -312,8 +312,6 @@ agents:
312312
features:
313313
auto_save: true
314314
show_tokens: true
315-
paths:
316-
save_location: ~/code-conversations/clara
317315
behavior:
318316
timeout: 300.0
319317
ui:
@@ -540,8 +538,7 @@ features:
540538
readline_enabled: boolean
541539

542540
paths:
543-
save_location: string # Path with ~ and $VAR expansion
544-
log_location: string
541+
log_location: string # Path with ~ and $VAR expansion
545542

546543
behavior:
547544
max_retries: integer # 0-10 recommended

src/basic_agent_chat_loop/chat_config.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class ChatConfig:
4444
"readline_enabled": True,
4545
},
4646
"paths": {
47-
"save_location": "~/agent-conversations",
4847
"log_location": "~/.chat_loop_logs",
4948
},
5049
"behavior": {
@@ -363,8 +362,8 @@ def initialize_default_config() -> Path:
363362
# ============================================================================
364363
# PATHS - File system locations
365364
# ============================================================================
365+
# Note: Conversations saved to ./.chat-sessions (project-local, not configurable)
366366
paths:
367-
save_location: ~/agent-conversations # Where to save conversations
368367
log_location: ~/.chat_loop_logs # Where to write logs (in home directory)
369368
370369
# ============================================================================
@@ -417,8 +416,6 @@ def initialize_default_config() -> Path:
417416
# features:
418417
# auto_save: true
419418
# show_tokens: true
420-
# paths:
421-
# save_location: ~/my-agent-conversations
422419
423420
agents: {}
424421
"""

src/basic_agent_chat_loop/chat_loop.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -635,14 +635,8 @@ def __init__(
635635
)
636636

637637
# Setup session manager for conversation persistence
638-
sessions_dir = (
639-
self.config.expand_path(
640-
self.config.get("paths.save_location", "~/agent-conversations")
641-
)
642-
if self.config
643-
else Path.home() / "agent-conversations"
644-
)
645-
self.session_manager = SessionManager(sessions_dir=sessions_dir)
638+
# Sessions are saved to ./.chat-sessions in current directory
639+
self.session_manager = SessionManager()
646640

647641
# Setup Harmony processor if agent uses Harmony format
648642
self.harmony_processor = None
@@ -2895,17 +2889,8 @@ def main():
28952889

28962890
# Handle session management commands
28972891
if args.list_sessions:
2898-
# List sessions and exit
2899-
config = get_config(config_path=args.config) if args.config else get_config()
2900-
sessions_dir = (
2901-
config.expand_path(
2902-
config.get("paths.save_location", "~/agent-conversations")
2903-
)
2904-
if config
2905-
else Path.home() / "agent-conversations"
2906-
)
2907-
2908-
session_manager = SessionManager(sessions_dir=sessions_dir)
2892+
# List sessions and exit (from ./.chat-sessions in current directory)
2893+
session_manager = SessionManager()
29092894
sessions = session_manager.list_sessions(limit=50)
29102895

29112896
if sessions:
@@ -2924,7 +2909,7 @@ def main():
29242909
print(f" {Colors.system('chat_loop <agent> --resume <session_id>')}")
29252910
else:
29262911
print(f"\n{Colors.system('No saved sessions found')}")
2927-
print(f"Sessions will be saved to: {sessions_dir}")
2912+
print("Sessions will be saved to: ./.chat-sessions")
29282913

29292914
sys.exit(0)
29302915

src/basic_agent_chat_loop/components/config_wizard.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ def reset_config_to_defaults() -> Optional[Path]:
9090
"spinner_style": "dots",
9191
},
9292
"paths": {
93-
"save_location": "~/agent-conversations",
9493
"log_location": "~/.chat_loop_logs",
9594
},
9695
}
@@ -650,15 +649,8 @@ def _configure_paths(self):
650649

651650
self.config["paths"] = {}
652651

653-
# save_location
654-
current_save_location = (
655-
self.current_config.get("paths.save_location", "~/agent-conversations")
656-
if self.current_config
657-
else "~/agent-conversations"
658-
)
659-
print("Where to save conversations (supports ~ for home directory)")
660-
save_loc = input(f"Save location [{current_save_location}]: ").strip()
661-
self.config["paths"]["save_location"] = save_loc or current_save_location
652+
# Conversations are now saved to ./.chat-sessions (project-local)
653+
# No configuration needed
662654

663655
# log_location
664656
current_log_location = (

src/basic_agent_chat_loop/components/display_manager.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,7 @@ def display_banner(self):
128128
print()
129129
print(Colors.DIM + "Configuration loaded" + Colors.RESET)
130130
if self.auto_save:
131-
save_loc = self.config.get(
132-
"paths.save_location",
133-
"~/agent-conversations",
134-
agent_name=self.agent_name,
135-
)
136-
print(f" Auto-save: enabled → {save_loc}")
131+
print(" Auto-save: enabled → ./.chat-sessions")
137132

138133
print("=" * 60)
139134

src/basic_agent_chat_loop/components/session_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ def __init__(self, sessions_dir: Optional[Path] = None):
6565
6666
Args:
6767
sessions_dir: Directory for session files
68-
(defaults to ~/agent-conversations)
68+
(defaults to ./.chat-sessions in current directory)
6969
"""
70-
self.sessions_dir = sessions_dir or Path.home() / "agent-conversations"
70+
self.sessions_dir = sessions_dir or Path.cwd() / ".chat-sessions"
7171
self.index_file = self.sessions_dir / ".index.json"
7272

7373
def _ensure_sessions_dir(self) -> bool:

tests/unit/test_config_wizard.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,21 +465,23 @@ class TestConfigurePaths:
465465
@patch("builtins.input")
466466
def test_configure_paths_defaults(self, mock_input, wizard):
467467
"""Test configuring paths with defaults."""
468-
mock_input.side_effect = ["", ""]
468+
mock_input.side_effect = [""]
469469

470470
wizard._configure_paths()
471471

472-
assert wizard.config["paths"]["save_location"] == "~/agent-conversations"
472+
# save_location no longer configurable (uses ./.chat-sessions)
473+
assert "save_location" not in wizard.config["paths"]
473474
assert wizard.config["paths"]["log_location"] == "~/.chat_loop_logs"
474475

475476
@patch("builtins.input")
476477
def test_configure_paths_custom_values(self, mock_input, wizard):
477478
"""Test configuring paths with custom values."""
478-
mock_input.side_effect = ["~/custom/conversations", "~/custom/logs"]
479+
mock_input.side_effect = ["~/custom/logs"]
479480

480481
wizard._configure_paths()
481482

482-
assert wizard.config["paths"]["save_location"] == "~/custom/conversations"
483+
# save_location no longer configurable (uses ./.chat-sessions)
484+
assert "save_location" not in wizard.config["paths"]
483485
assert wizard.config["paths"]["log_location"] == "~/custom/logs"
484486

485487

0 commit comments

Comments
 (0)