Initialize and configure the fractary-file plugin
Sets up the fractary-file plugin with interactive configuration wizard for storage handlers.
/plugin marketplace add fractary/claude-plugins/plugin install fractary-file@fractaryclaude-haiku-4-5Initialize the fractary-file plugin with interactive configuration wizard.
<CONTEXT> You are the init command for the fractary-file plugin. Your role is to parse arguments and immediately invoke the config-wizard skill to guide users through setup. </CONTEXT><CRITICAL_RULES>
Examples:
# Interactive setup (prompts for handler selection)
/fractary-file:init
# Setup S3 only
/fractary-file:init --handlers s3
# Setup multiple handlers (local and S3)
/fractary-file:init --handlers local,s3
# Setup all cloud handlers
/fractary-file:init --handlers r2,s3,gcs
# Non-interactive setup using environment variables
/fractary-file:init --handlers r2,s3 --non-interactive
# Setup without connection test
/fractary-file:init --handlers local --no-test
</INPUTS>
<WORKFLOW>
Display welcome banner:
๐๏ธ Fractary File Plugin Configuration
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
This wizard will help you configure file storage for your project.
You can configure multiple storage providers and choose a default.
Different files can use different storage locations as needed.
Default: Local filesystem storage (zero configuration required)
Supported: Local, Cloudflare R2, AWS S3, Google Cloud Storage, Google Drive
Press Ctrl+C at any time to cancel.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Extract from user input:
handlers: comma-separated list or null (prompts user)interactive: true or false (default: true)test_connection: true or false (default: true)Handle both --handler (deprecated) and --handlers (current):
HANDLERS=""
# Check for both flags
if [ -n "$FLAG_HANDLERS" ]; then
# New flag: --handlers local,s3,r2
HANDLERS="$FLAG_HANDLERS"
elif [ -n "$FLAG_HANDLER" ]; then
# Old flag: --handler s3 (convert to new format)
HANDLERS="$FLAG_HANDLER"
echo "โ ๏ธ Note: --handler is deprecated. Use --handlers instead."
echo " Converted: --handler $FLAG_HANDLER โ --handlers $HANDLERS"
fi
Conversion Examples:
--handler s3 โ --handlers s3 (single handler)Validate and normalize handler list:
# Remove duplicates and validate
if [ -n "$HANDLERS" ]; then
# Convert comma-separated string to array
IFS=',' read -ra HANDLER_ARRAY <<< "$HANDLERS"
# Remove duplicates
UNIQUE_HANDLERS=($(echo "${HANDLER_ARRAY[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
# Validate each handler
VALID_HANDLERS=("local" "r2" "s3" "gcs" "gdrive")
for handler in "${UNIQUE_HANDLERS[@]}"; do
if [[ ! " ${VALID_HANDLERS[@]} " =~ " ${handler} " ]]; then
echo "โ Error: Invalid handler '$handler'"
echo ""
echo "Valid handlers: ${VALID_HANDLERS[@]}"
exit 1
fi
done
# Rebuild cleaned handlers list
HANDLERS=$(IFS=,; echo "${UNIQUE_HANDLERS[*]}")
fi
# Default handling
if [ "$INTERACTIVE" = "false" ] && [ -z "$HANDLERS" ]; then
HANDLERS="local"
echo "โน๏ธ Non-interactive mode with no handler specified, defaulting to 'local'"
fi
Edge Cases Handled:
--handlers local,s3,local โ local,s3--handlers s3,invalid โ Error with valid optionslocalCRITICAL: When no --handlers argument is provided, intelligently detect which handlers to configure:
# Default handling
if [ -z "$HANDLERS" ]; then
# Always include local
HANDLERS="local"
# In interactive mode or if AWS profiles exist, add S3
if [ "$INTERACTIVE" = "true" ]; then
# Interactive: always offer S3 configuration
HANDLERS="local,s3"
echo "โน๏ธ No handler specified, defaulting to 'local,s3' (local for development, S3 for production)"
echo " Use --handlers to override this default"
else
# Non-interactive: only add S3 if AWS profiles/credentials exist
if [ -f "$HOME/.aws/config" ] || [ -f "$HOME/.aws/credentials" ]; then
HANDLERS="local,s3"
echo "โน๏ธ Non-interactive mode: detected AWS configuration, defaulting to 'local,s3'"
else
HANDLERS="local"
echo "โน๏ธ Non-interactive mode: no AWS configuration detected, defaulting to 'local' only"
echo " Use --handlers local,s3 to configure S3"
fi
fi
fi
Rationale:
local: Always included, no credentials needed, ideal for development and testings3: Added intelligently:
This ensures consistent behavior while respecting the environment:
--handlers argumentBreaking Change Notice:
local,s3 (interactive) or local (non-interactive without AWS)--handlers flagThe handlers parameter goes through several transformations:
CLI Flag โ String โ Array โ String โ Array (in config-wizard)
Detailed Flow:
CLI Input (User):
/fractary-file:init --handlers local,s3,r2
Parsed as String (init command, Step 2.1):
HANDLERS="local,s3,r2"
Converted to Array for Validation (init command, Step 2.2):
IFS=',' read -ra HANDLER_ARRAY <<< "$HANDLERS"
# HANDLER_ARRAY=("local" "s3" "r2")
Validated and De-duplicated (init command, Step 2.2):
UNIQUE_HANDLERS=($(echo "${HANDLER_ARRAY[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
Converted Back to String (init command, Step 2.2):
HANDLERS=$(IFS=,; echo "${UNIQUE_HANDLERS[*]}")
# HANDLERS="local,r2,s3" (sorted, de-duped)
Passed to Skill as String (init command, Step 3):
{
"skill": "config-wizard",
"parameters": {
"handlers": "local,r2,s3"
}
}
Converted to Array in Skill (config-wizard, Phase 2.1):
IFS=',' read -ra HANDLER_LIST <<< "$HANDLERS"
# HANDLER_LIST=("local" "r2" "s3")
Iterated Over (config-wizard, Phase 3.0.1):
for HANDLER in "${HANDLER_LIST[@]}"; do
# Configure each handler
done
Why String โ Array โ String โ Array?
Use the @agent-fractary-file:file-manager agent to invoke the config-wizard skill with:
{
"skill": "config-wizard",
"parameters": {
"handlers": "local,s3,r2|s3|null",
"interactive": true|false,
"test_connection": true|false
}
}
Note: Pass handlers as comma-separated string, not as array.
After skill completes, show final summary:
โ
Configuration complete!
Configured handlers: {handler1, handler2, ...}
Default handler: {active_handler}
Location: {config_path}
Status: {tested ? "Tested and working" : "Saved (not tested)"}
Next steps:
โข Test connection: /fractary-file:test-connection
โข Upload a file: Use @agent-fractary-file:file-manager
โข Override handler for specific operations with handler_override
โข Switch default: /fractary-file:switch-handler
โข View config: /fractary-file:show-config
Documentation: plugins/file/README.md
</WORKFLOW>
<ERROR_HANDLING>
bash plugins/file/skills/config-wizard/scripts/init.sh
The script will:
.fractary/plugins/file/config.json with local handler as defaultWith options:
# Force overwrite existing config
bash plugins/file/skills/config-wizard/scripts/init.sh --force
# Specify handler (for future use)
bash plugins/file/skills/config-wizard/scripts/init.sh --handler local
After running the script:
Success output should include:
โ
Fractary File Plugin initialized!
Configuration: .fractary/plugins/file/config.json
Default handler: local
Next steps:
1. Test connection: /fractary-file:test-connection
2. Add cloud handlers (S3, R2, etc.): Edit the config file
3. Upload a file: Use @agent-fractary-file:file-manager
Adding Additional Handlers:
To add S3, R2, or other handlers, edit .fractary/plugins/file/config.json and add handler sections from the example config at plugins/file/config/config.example.json.
</IMPLEMENTATION>