Harden CLI parsing and centralize command directory structure#108
Open
lsr00ter wants to merge 1 commit into
Open
Harden CLI parsing and centralize command directory structure#108lsr00ter wants to merge 1 commit into
lsr00ter wants to merge 1 commit into
Conversation
- Introduce CLAUDEBOX_GLOBAL_CLAUDE_COMMANDS_DIR (~/.claudebox/.claude/commands)
and migrate references from ~/.claude/commands; preserve legacy commands by
copying them into the new location on setup.
- Expand SCRIPT_COMMANDS list (update, import, unlink, undo, redo, config, mcp,
migrate-installer) and add did-you-mean suggestions for unknown commands via
get_script_command_suggestion().
- Make array expansions safe under set -u using ${arr[@]+"${arr[@]}"} across
cli, config, docker, profile, and main flows.
- Strip trailing whitespace and minor markdown formatting cleanup in README and
commands/controlflow.md.
Reviewer's GuideCentralizes Claude command storage under a new ~/.claudebox/.claude/commands directory (with migration from legacy paths), hardens bash scripts for set -u and array usage, expands and improves CLI command parsing (including more script commands and did-you-mean suggestions), and performs small documentation/whitespace cleanups. Class diagram for updated CLI, environment, and command sync modulesclassDiagram
class Env {
<<module>>
+USER_ID
+GROUP_ID
+PROJECT_DIR
+CLAUDEBOX_HOME
+CLAUDEBOX_GLOBAL_CLAUDE_DIR
+CLAUDEBOX_GLOBAL_CLAUDE_COMMANDS_DIR
}
class CLI {
<<module>>
+HOST_ONLY_FLAGS
+CONTROL_FLAGS
+SCRIPT_COMMANDS
+CLI_HOST_FLAGS
+CLI_CONTROL_FLAGS
+CLI_SCRIPT_COMMAND
+CLI_PASS_THROUGH
+parse_cli_args(args)
+process_host_flags()
+get_script_command_requirements(cmd, subcommand)
+requires_docker_image()
+requires_slot(cmd)
+debug_parsed_args()
+get_script_command_suggestion(input)
+_is_close_command_match(left, right)
}
class Main {
<<module>>
+main(args)
+show_first_time_welcome()
+build_docker_image()
}
class State {
<<module>>
+update_symlink()
+setup_shared_commands()
+setup_claude_agent_command(parent_dir)
+calculate_docker_layer_checksums(project_dir)
+needs_docker_rebuild(project_dir, image_name)
+save_docker_layer_checksums(project_dir)
}
class ProjectModule {
<<module>>
+init_project_dir(path)
+get_project_folder_name(path)
+sync_commands_to_project(project_parent)
+list_all_projects()
+list_project_slots(path)
}
class ConfigModule {
<<module>>
+read_profile_section(profile_file, section)
+update_profile_section(profile_file, section, new_items)
+get_current_profiles()
}
class DockerModule {
<<module>>
+run_claudebox_container(container_name, run_mode, container_args)
+run_docker_build(dockerfile, build_context)
+check_container_exists(container_name)
}
Env <.. CLI : uses env constants
Env <.. Main : uses PROJECT_DIR, CLAUDEBOX_HOME
Env <.. State : uses CLAUDEBOX_HOME\nCLAUDEBOX_GLOBAL_CLAUDE_COMMANDS_DIR
Env <.. ProjectModule : uses CLAUDEBOX_HOME
Main --> CLI : calls parse_cli_args()\nprocess_host_flags()\nget_script_command_suggestion()
Main --> DockerModule : calls run_claudebox_container()\nrun_docker_build()
Main --> State : calls update_symlink()\nsetup_shared_commands()\nneeds_docker_rebuild()
Main --> ProjectModule : calls init_project_dir()\nsync_commands_to_project()
Main --> ConfigModule : calls get_current_profiles()
State --> ProjectModule : setup_claude_agent_command()\nrelies on project parent
ProjectModule --> State : uses calculate_docker_layer_checksums()\nvia rebuild logic
CLI --> ConfigModule : get_command_requirements()\ninteracts via requires_slot()
DockerModule --> ProjectModule : uses get_slot_index()
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
build_docker_image, the guard that checks for unreplaced Dockerfile placeholders (grep -q '{{PROFILE_INSTALLATIONS}}'andgrep -q '{{LABELS}}') is missing a command separator or logical operator between the twogrepinvocations, which will cause a syntax/runtime error; this should be rewritten with||or similar so both checks run correctly. - In
setup_shared_commands, thefor file in "$legacy_commands"/*; doloop will iterate over the literal pattern when the legacy directory is empty, which can generate spurious errors; consider enablingnullgloblocally or checking for at least one regular file before entering the loop to make the migration more robust.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `build_docker_image`, the guard that checks for unreplaced Dockerfile placeholders (`grep -q '{{PROFILE_INSTALLATIONS}}'` and `grep -q '{{LABELS}}'`) is missing a command separator or logical operator between the two `grep` invocations, which will cause a syntax/runtime error; this should be rewritten with `||` or similar so both checks run correctly.
- In `setup_shared_commands`, the `for file in "$legacy_commands"/*; do` loop will iterate over the literal pattern when the legacy directory is empty, which can generate spurious errors; consider enabling `nullglob` locally or checking for at least one regular file before entering the loop to make the migration more robust.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Centralize Claude command storage under a new global ClaudeBox directory, harden CLI parsing and Docker/mcp flows for unset variables, and improve usability with command suggestions and documentation updates.
New Features:
Enhancements:
Documentation: