这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@ryanrozich
Copy link

@ryanrozich ryanrozich commented Nov 14, 2025

feat: Add multi-profile thoughts repository support

Problem

Developers working across multiple organizations (personal projects, multiple clients) currently need to manually manage separate thoughts configurations through complex symlink setups. Each context requires switching configurations, making it difficult to maintain separate thought repositories for different work contexts.

Solution

This PR adds multi-profile support to the thoughts system, enabling developers to maintain separate thoughts repositories that automatically switch based on the current code repository.

Developer Experience:

# Create profiles for different contexts
humanlayer thoughts profile create personal --repo ~/thoughts-personal
humanlayer thoughts profile create client-acme --repo ~/thoughts-acme

# Initialize repos with profiles - one command, fully automatic
cd ~/projects/personal-app
humanlayer thoughts init --profile personal

cd ~/clients/acme/project
humanlayer thoughts init --profile client-acme

# Everything just works - sync, status, all commands use the right repo
humanlayer thoughts sync    # Automatically uses correct profile's repo
humanlayer thoughts status  # Shows current profile

Key Benefits:

  • 🎯 Automatic context switching - No manual configuration needed
  • 🔒 Complete isolation - Separate repos for personal vs. client work
  • Zero breaking changes - Existing setups continue working unchanged
  • 🚀 Simple commands - Four new profile management commands

Implementation

New Commands:

  • humanlayer thoughts profile create/list/show/delete - Manage profiles

Updated Commands:

  • init - Added --profile flag, uses profile-specific paths
  • sync/status/config/uninit - Automatically detect and use correct profile

Code Changes:

  • Added ProfileConfig and RepoMappingObject types for configuration
  • Implemented resolveProfileForRepo() for automatic profile detection
  • Extended existing commands with profile awareness via function overloads
  • Maintained backward compatibility with string-format mappings

Files Changed: 13 files (+799/-77 lines)

  • 4 new profile management commands
  • Core resolution logic in thoughtsConfig.ts
  • Profile-aware updates to all existing commands
  • Documentation and examples

Verification

Automated:

  • Build passes ✅
  • All 61 tests pass (27 existing + 34 new profile resolution tests) ✅
  • TypeScript compilation clean ✅

Test Coverage: Added comprehensive unit tests for profile resolution logic, including edge cases, backward compatibility, and helper functions (Vitest framework).

Manual Testing:

  1. Create multiple profiles in different contexts
  2. Initialize repos with --profile flag
  3. Verify sync targets correct repository
  4. Confirm backward compatibility (init without --profile uses default)

Migration

No migration required. Feature is opt-in:

  • Existing repos continue using default config
  • New repos can use --profile for separate contexts
  • String-format mappings remain fully supported

Related


Summary: Developers can now manage multiple thoughts repositories for different work contexts with simple profile commands, eliminating manual configuration while maintaining full backward compatibility.

…ughts support

- Add RepoMappingObject and ProfileConfig types to support profile-based configuration
- Extend ConfigFile type to include optional profiles field
- Update ThoughtsConfig interface to support both string and object mapping formats
- Add ResolvedProfileConfig interface for profile resolution results
- Implement resolveProfileForRepo() function for automatic profile detection
- Add helper functions for mapping format conversion and profile validation
- Update all path resolution functions with function overloads for backward compatibility

Refs: humanlayer#843
- Add 'humanlayer thoughts profile create' command with interactive and non-interactive modes
- Add 'humanlayer thoughts profile list' command with JSON output support
- Add 'humanlayer thoughts profile show' command for viewing profile details
- Add 'humanlayer thoughts profile delete' command with safety checks
- Register all profile subcommands in thoughts command group
- Support profile validation, sanitization, and usage tracking

Users can now create and manage multiple named thoughts profiles for different
organizational contexts (personal, client A, client B, etc.).

Refs: humanlayer#843
- init: Add --profile option and early profile resolution (tempProfileConfig)
- init: Use profile config for directory listings and path messages
- init: Write object-format mappings when profile specified
- sync: Resolve profile and use correct thoughtsRepo for git operations
- status: Display profile information and use profile's repo for git status
- config: Show profiles and handle new mapping format in display
- uninit: Handle object-format mappings and show correct profile repo path

All commands now automatically detect and use the correct profile based on
repository mappings. Includes fix for bug where init command was using default
thoughtsRepo for messages when --profile was specified.

Refs: humanlayer#843
- Add comprehensive profile management section to README
- Include examples of profile creation, usage, and management
- Document --profile flag for init command
- Explain profile features and use cases
- Provide configuration examples

Refs: humanlayer#843
@CLAassistant
Copy link

CLAassistant commented Nov 14, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed everything up to 2f7ed8f in 1 minute and 0 seconds. Click for details.
  • Reviewed 1341 lines of code in 13 files
  • Skipped 0 files when reviewing.
  • Skipped posting 10 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. hlyr/src/commands/thoughts.ts:21
  • Draft comment:
    Good addition of the '--profile' option to the init command. It clearly exposes multi-profile support.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
2. hlyr/src/commands/thoughts/config.ts:55
  • Draft comment:
    Profile details are now printed alongside repo mappings. The code cleanly distinguishes default vs. profile mappings.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
3. hlyr/src/commands/thoughts/init.ts:400
  • Draft comment:
    The profile validation logic is clear, but similar prompt functions are re‐implemented. Consider extracting a shared utility to reduce duplication.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
4. hlyr/src/commands/thoughts/init.ts:605
  • Draft comment:
    The update to repoMappings (object vs. string) is handled well for backward compatibility. Verify that downstream commands correctly interpret both formats.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
5. hlyr/src/commands/thoughts/profile/create.ts:20
  • Draft comment:
    The interactive prompts for profile creation work as intended. As with init, consider abstracting the prompt functionality to a common helper for maintainability.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
6. hlyr/src/commands/thoughts/sync.ts:238
  • Draft comment:
    Passing profileConfig.thoughtsRepo to syncThoughts works, but note that syncThoughts uses a legacy signature. Consider refactoring to accept a profile config object for consistency.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
7. hlyr/src/thoughtsConfig.ts:249
  • Draft comment:
    Overloaded functions (ensureThoughtsRepoExists, getRepoThoughtsPath, createThoughtsDirectoryStructure, updateSymlinksForNewUsers) correctly handle legacy and new profile support. Adding inline comments to explain the parameter differences could improve readability.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
8. hlyr/src/thoughtsConfig.ts:256
  • Draft comment:
    The sanitizeProfileName function reuses directory naming rules, which is consistent with other naming conventions. This is a good design choice.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
9. hlyr/src/config.ts:10
  • Draft comment:
    Type definitions for RepoMappingObject and ProfileConfig are clear and help support multi-profile functionality. No issues here.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
10. hlyr/src/commands/thoughts/uninit.ts:36
  • Draft comment:
    The uninit command properly handles profile-based configurations and informs the user of the associated profile mapping. This is clear and well implemented.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None

Workflow ID: wflow_aDxfI6EThOVA64Oo

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

- Add 34 unit tests covering all profile-related functionality
- Test resolveProfileForRepo() with all edge cases (string, object, invalid profiles)
- Test helper functions (getRepoNameFromMapping, getProfileNameFromMapping)
- Test profile validation and name sanitization
- Test backward compatibility with legacy configs
- All 61 tests passing (27 existing + 34 new)

Coverage includes:
- Profile resolution for string/object mappings
- Fallback behavior for invalid profiles
- Mixed legacy and new format mappings
- Edge cases (undefined profiles, empty configs, special characters)
- Profile name sanitization rules

Refs: humanlayer#843
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support multiple thoughts repositories via profiles/contexts

2 participants