Commit Graph

30 Commits

Author SHA1 Message Date
Harry 0be17fa1a7 feat: update tool management and configuration handling
- Changed the tool fetching mechanism to handle missing tools more effectively by introducing a batch fetch method.
- Removed the pull command to streamline the CLI, focusing on tool references and their management.
- Enhanced the list command to display available tool references and their statuses, improving user visibility into tool availability.
- Updated the configuration structure to include new fields for tool references and their enabled status.

This update improves the overall tool management experience in the CLI, making it more efficient and user-friendly.
2026-01-30 03:30:01 +08:00
Harry b967831c68 refactor: simplify init command by removing tool handling
- Removed the handling of tools from the init command, focusing solely on tool references.
- Updated output messages to reflect the changes in functionality, improving clarity for users.

This refactor streamlines the initialization process by concentrating on tool references, enhancing user experience.
2026-01-22 18:14:25 +08:00
Harry be1e8e8dd4 fix: update output for missing tools in config
- Changed error message output from stderr to stdout when no tools or tool references are defined in the configuration.
- Added support for custom configuration path via the DIFY_CLI_CONFIG environment variable.

This update improves user experience by providing clearer output and flexibility in configuration management.
2026-01-21 14:54:51 +08:00
Harry 4fa55bcdf5 feat: support tool references 2026-01-19 23:03:54 +08:00
Harry bf34c871bb feat: implement file upload 2026-01-13 18:01:54 +08:00
Harry 24cee3b2e7 feat: enhance help command output for tool parameters
- Added detailed descriptions for tool parameter types in the help command, including options for "select", "file", "files", "boolean", and "number".
- Improved user guidance by specifying accepted values and formats for each parameter type.

This update enhances the usability of the CLI by providing clearer information on tool parameters during help command execution.
2026-01-13 16:56:15 +08:00
Harry 6b68394641 fix: enhance error reporting for non-200 API responses
- Improved error handling in the callDifyAPI function by reading the response body for non-200 status codes.
- This change ensures that error messages include the actual response content, providing better context for debugging.

This update enhances the clarity of error reporting during API interactions.
2026-01-12 20:20:44 +08:00
Harry b7c22eea22 fix: improve error handling for API responses in callDifyAPI
- Added a check for the API response status code in the callDifyAPI function to handle non-200 responses more effectively.
- Enhanced error reporting by including the status code and response body in the error message.

This update improves the robustness of API interactions by ensuring that errors are clearly communicated to the user.
2026-01-12 20:11:57 +08:00
Harry 69cb144fe0 feat: update CLI configuration and API request handling
- Updated the .dify_cli.json configuration to include cli_api_url, cli_api_session_id, and cli_api_secret for improved API interaction.
- Refactored the callDifyAPI and fetchProviders functions to utilize the new CLI API structure, including HMAC signature generation for enhanced security.
- Modified EnvConfig to reflect the new CLI API parameters, ensuring required fields are validated.

This update enhances the security and functionality of the CLI by transitioning to a new API structure and improving request handling.
2026-01-12 19:55:38 +08:00
Harry de24e0b2a9 refactor: update tool parameter handling and types
- Replaced references to plugin_entities and requests with the new types package for tool parameters and descriptions.
- Enhanced the structure of tool parameters and descriptions to include LLM descriptions and improved type definitions.
- Updated the .dify_cli.json configuration to reflect changes in session ID format for enhanced security.

This refactor improves code organization and type safety, streamlining the handling of tool parameters in the CLI.
2026-01-04 19:36:55 +08:00
Harry 10d34daa29 refactor: update configuration to use inner_api_session_id
- Replaced inner_api_key and user_id with inner_api_session_id in the .dify_cli.json configuration.
- Updated EnvConfig and related functions to reflect the new session-based authentication.
- Removed obsolete tenant_id and user_id fields from the configuration and API request handling.

This update enhances security by transitioning to session-based authentication and streamlining the configuration structure.
2026-01-04 16:23:40 +08:00
Harry dc53c0b3e3 feat: add env command to output shell commands for PATH configuration
- Introduced a new `env` command that outputs the necessary shell command to add the current working directory to the user's PATH.
- Updated the `runInit` function to inform users about the new `env` command for adding tools to PATH.

This update enhances the CLI by providing users with a convenient way to configure their environment for tool usage.
2026-01-04 11:38:47 +08:00
Harry 1c800b1019 fix: improve output handling in init command
- Updated output statements in the runInit function to use fmt.Fprintf for consistent error and status reporting.
- Changed messages for missing tools and existing symlinks to direct output to the appropriate streams (stderr for errors, stdout for status).

This update enhances the clarity and consistency of command output in the CLI tool.
2026-01-04 11:31:48 +08:00
Harry 97a7149b18 fix: enforce required validation for FilesURL in EnvConfig
- Updated the EnvConfig struct to mark the FilesURL field as required, ensuring proper validation during configuration loading.
- This change enhances the robustness of the configuration management by preventing incomplete setups.
2026-01-02 15:49:47 +08:00
Harry 34b479fe02 feat: update .dify_cli.json configuration to remove obsolete tools and add files_url
- Removed all tool definitions from the .dify_cli.json file to streamline configuration.
- Added a new `files_url` field to the environment section for improved resource management.

This update simplifies the configuration file and enhances the management of file resources.
2026-01-02 15:46:10 +08:00
Harry 2bb1b2f521 feat: add pull command to fetch and save tools from Dify
- Introduced a new `pull` command that retrieves all available tools from the Dify platform and saves them to the `.dify_cli.json` configuration file.
- Implemented error handling for API requests and configuration saving to enhance reliability.
- Updated the command initialization to include the new `pull` command in the CLI structure.
- Enhanced the `EnvConfig` struct to include a `FilesURL` field for better tool management.

This update improves the CLI's functionality by allowing users to easily pull and manage tools from the Dify platform.
2026-01-02 15:42:10 +08:00
Harry 944defac2a feat: enhance argument handling in InvokeTool function
- Updated the argument check in the InvokeTool function to display help information when the first argument is either empty or a help flag ("--help" or "-h").
- This improvement ensures users receive guidance on tool usage when invoking without specific commands.

This update enhances user experience by providing immediate help options for the CLI tools.
2025-12-30 18:05:01 +08:00
Harry 4522bfc094 feat: improve tool help display in execute command
- Added a check for empty arguments in the InvokeTool function to display tool help when no arguments are provided.
- Refactored the printToolHelp function to PrintToolHelp for consistency in naming conventions.

This update enhances user experience by providing immediate help information when invoking tools without arguments.
2025-12-30 18:03:47 +08:00
Harry ff13761290 feat: update tool description output in list command
- Changed the output format in the list command to display the LLM description instead of the human-readable description.
- Added a hidden help command and disabled the default command completion options for improved command structure.

This update enhances the clarity of tool descriptions in the CLI and improves command usability.
2025-12-30 17:30:31 +08:00
Harry 7ca7940ea7 feat: streamline API response output in execute.go
- Replaced individual data type handling with a unified JSON output for API responses.
- Added error handling for JSON marshaling to ensure robust output.
- Enhanced logging to provide clearer context during tool execution.

This update improves the clarity and consistency of API interaction outputs in the CLI tool.
2025-12-30 17:18:47 +08:00
Harry 644aa5cc72 feat: enhance API call handling in execute.go
- Added error handling for API responses, including checks for nil data and specific error messages.
- Implemented a timeout for the HTTP client to improve reliability during long-running requests.
- Refactored response processing to handle various data types (text, JSON, file, blob, link) more effectively.

This update improves the robustness and clarity of API interactions within the CLI tool.
2025-12-30 17:10:10 +08:00
Harry 6e04ebb9da feat: add .dify_cli.json configuration file and enhance command initialization
- Introduced a new .dify_cli.json file to define environment variables and tool configurations.
- Updated command initialization to create symlinks for tools defined in the new configuration file.
- Improved error handling and output messages during symlink creation.
- Removed obsolete environment file and related loading functions to streamline configuration management.

This update enhances the CLI's flexibility and usability by allowing dynamic tool management through JSON configuration.
2025-12-30 16:49:57 +08:00
Harry 74e6fdf442 refactor: remove obsolete test files and streamline config handling
- Deleted execute_test.go and config_test.go as they are no longer needed.
- Updated init.go to improve error handling and configuration validation.
- Simplified GetConfigPath and related functions for better clarity.
- Enhanced EnvConfig struct with validation tags for required fields.

This cleanup enhances code maintainability and reduces unnecessary complexity.
2025-12-30 16:12:35 +08:00
Harry 6527ddb0f2 refactor: introduce new json schema structure 2025-12-30 16:04:08 +08:00
Harry 92dfaab6fc refactor: restructure dify CLI command handling
- Moved command definitions and execution logic to a new root.go file for better organization.
- Simplified main.go by delegating command execution to the new structure.
- Enhanced symlink detection for BusyBox-style invocation.

This refactor improves code maintainability and clarity in the CLI tool's architecture.
2025-12-30 12:51:20 +08:00
Harry cbb12bcf6f refactor: use symlink detection instead of hardcoded names
Use isSymlinkToSelf() to detect BusyBox-style invocation by checking
if os.Args[0] resolves to the same path as the current executable.
This eliminates the need to hardcode special names like "main" or
"__debug_bin", and works correctly with go run.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 12:27:52 +08:00
Harry 8379d2673b refactor: separate tool schemas from env config
- Change schema format to flat {"tools": [...]} structure
- Add Provider field to EnvConfig for API calls
- Remove provider nesting, use simple ToolSchemas type
- Update FindTool to return only tool (no provider)
- Update all commands to use new structure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 11:33:53 +08:00
Harry 066e5864e6 refactor: reuse daemon's http_requests and dify_invocation for API calls
- Add TenantID and UserID to EnvConfig
- Update config loading to parse TENANT_ID and USER_ID from env file
- Rewrite callDifyAPI to use daemon's http_requests.PostAndParseStream
- Use dify_invocation.InvokeToolRequest and tool_entities.ToolResponseChunk
- Update tests to verify new config fields

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 11:21:29 +08:00
Harry b0eaddfe60 fix: use positional arg for tool name in execute command
Change from `dify execute --tool name` to `dify execute name` to avoid
flag name conflicts with tool parameters.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 11:13:16 +08:00
Harry f90cd8aa9a feat: add dify_cli BusyBox-style CLI tool
Add a new CLI tool that allows invoking Dify platform tools like bash commands.

Features:
- BusyBox-style symlink invocation (e.g., google_search --query "hello")
- Cobra-based command structure for dify init/execute/list
- Flag-style parameters (--param value) instead of JSON
- Supports tool schema from Dify plugin entities

Usage:
  dify init --env <file> --schemas <file>   # Initialize config and create symlinks
  dify execute --tool <name> [--args...]    # Execute tool directly
  dify list                                 # List available tools
  google_search --query "hello"             # Via symlink

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 11:09:02 +08:00