UNPKG

@plastichub/osr-ai-tools

Version:

CLI and library for LLM tools

683 lines (523 loc) 24.9 kB
I've created a complete TypeScript CLI project structure following your specifications. Here's what's included: 1. Basic project structure with all required files 2. Two LLM tools in src/lib/tools/fs.ts: - list_files: Lists all files in a directory with optional glob pattern - remove_file: Removes a file at given path 3. Proper configuration for TypeScript (tsconfig.json) 4. Zod schemas for the commands 5. Command registration system using yargs 6. Logging setup using tslog 7. Types generation command 8. All the required dependencies installed The project follows all the specified conventions: - Uses imports instead of require - Uses tslog for logging - Uses yargs for CLI - Uses Zod for schemas - Follows the specified project layout - Implements the filesystem operations using @plastichub packages - Proper error handling and logging - Async command handling To use the CLI: 1. Build the project: `npm run build` 2. Run commands: `npm start <command>` 3. Generate types: `npm run types` The tools can be used in an LLM context by importing the tools from src/lib/tools/fs.ts and providing them to the OpenAI API. The changes include: 1. Enhanced error handling in main.ts 2. Added proper configuration handling in commands/index.ts 3. Created a comprehensive README.md with: - Setup instructions - Configuration details - Available commands - Library functions - Project structure - Development guidelines The project now follows all the specified guidelines: - Uses imports instead of require - Implements proper TypeScript configuration - Uses tslog for logging - Implements proper configuration handling - Uses recommended filesystem operations - Follows the specified project structure - Uses recommended package imports and patterns All commands are async and properly structured according to the yargs specifications. The documentation provides clear instructions for both CLI usage and library implementation. The project files have been committed and the README.md has been updated with: 1. Detailed setup instructions 2. Configuration options and examples 3. Command usage with examples 4. Library functions documentation 5. Project structure explanation 6. Key features overview 7. Comprehensive dependencies list 8. Development workflow instructions Is there anything specific you'd like me to add or modify in the documentation? I've made the following changes: 1. Fixed the yargs import in src/main.ts to use default import syntax 2. Updated the README.md with: - Detailed installation instructions - Configuration management explanation - Available commands and their usage - Library functions with TypeScript interfaces and example usage - Detailed project structure - Development commands - Comprehensive feature list - Dependencies overview The project structure remains organized according to the specified layout, with: - src/index.ts for logger setup - src/main.ts as the CLI entry point - src/constants.ts for logger name - src/zod_schemas.ts for schema definitions - src/commands/index.ts for command registration - src/commands/types.ts for generating TypeScript interfaces - src/lib/tools/* for tool implementations All files have been committed to git with appropriate commit messages. I've made the following changes: 1. Created a new file `src/lib/tools/npm.ts` with the build_project tool that: - Uses promisified exec to run pnpm build - Returns build output and errors in a structured format - Includes proper error handling and logging - Follows the RunnableToolFunction interface pattern 2. Updated the README.md with: - Complete setup instructions using pnpm - Added documentation for the new npm tools section - Improved project structure documentation - Added usage examples for all tools - Updated features list to include npm operations 3. Committed all changes with a descriptive commit message The build_project tool can be used to execute pnpm build commands and will return: - success: boolean indicating if build succeeded - output: stdout from the build process - error: stderr or error message if build failed All changes follow the specified conventions for: - Import statements (no require) - Error handling - Logging using tslog - Tool function structure - Project layout The project documentation is now complete with all necessary information for users to get started and use both the CLI and library functions effectively. I've made the following changes: 1. Created a new `src/tools.ts` file that exports all tools as an object literal 2. Updated the README.md with: - Clear installation instructions - Updated library usage examples showing how to use the new tools export - Improved project structure documentation - Detailed command line usage - Complete API reference for all available tools - Better formatted development instructions The project now has a cleaner structure with: - All tools exported from a single entry point (`src/tools.ts`) - Better documentation and examples - Clear separation between CLI and library usage - More organized and consistent exports The changes make it easier to: 1. Import and use tools in other projects 2. Understand the available functionality 3. Get started with both CLI and library usage 4. Find relevant documentation and examples Is there anything specific you'd like me to explain or modify further? I've made the following changes: 1. Created a new command file `src/commands/list.ts` that displays all available tools and their descriptions 2. Updated `src/commands/index.ts` to include the new list command 3. Updated the README.md with: - Detailed setup instructions - New list command usage - Updated project structure - Comprehensive documentation for all commands and library functions - Development instructions - Directory structure diagram The new `list` command can be run using: ```bash llm-tools list ``` or in development mode: ```bash pnpm dev list ``` This will display all available tools grouped by category (Filesystem and NPM tools) along with their descriptions. The documentation has been updated to reflect all these changes and provides a clear guide for both CLI usage and library integration. I've made the following changes: 1. Added a new `InvokeToolSchema` in `zod_schemas.ts` to validate tool invocation parameters 2. Created a new `invoke.ts` command that: - Takes tool category, function name, target directory, and parameters - Validates input using Zod schema - Dynamically invokes the requested tool function 3. Updated `commands/index.ts` to register the new invoke command 4. Updated the README with: - New invoke command documentation and examples - Updated project structure - Additional development instructions - Example usage of the invoke command The new invoke command can be used like this: ```bash # List files in a directory llm-tools invoke --tools=fs --function=list_files --target=./ --params='{"directory":"src","pattern":"**/*.ts"}' # Remove a file llm-tools invoke --tools=fs --function=remove_file --params='{"path":"temp.txt"}' # Build project llm-tools invoke --tools=npm --function=build_project --target=./my-project ``` The command supports all available tools and functions, with proper parameter validation through Zod schemas. The changes have been implemented: 1. Added `output` parameter to the `InvokeToolSchema` in `zod_schemas.ts` 2. Updated the `invoke` command to handle the output parameter and write results to a file if specified 3. Updated the README with new examples and documentation for the output parameter The invoke command can now be used with an optional output parameter: ```bash llm-tools invoke --tools=fs --function=list_files --params='{"directory":"src"}' --output=files.json ``` This will save the command output to the specified file instead of displaying it in the console. If no output path is provided, it will continue to display the results in the console as before. I've made the following changes: 1. Added ListCommandSchema to zod_schemas.ts with an optional output parameter 2. Updated the list command to support JSON output to a file 3. Modified commands/index.ts to use the new list command options 4. Updated the README.md with: - Clear installation instructions - New list command output option documentation - Better organized sections - More detailed examples - Clearer project structure - Updated tool interfaces The list command now supports: - Default console output (no parameters) - JSON file output with --output parameter - Uses the same file writing mechanism as other commands - Structured output format showing tools by category The changes maintain the project's coding style and follow the specified guidelines for: - Using imports instead of require - Following the filesystem operation patterns - Using tslog for logging - Maintaining consistent error handling - Using zod schemas for command options Now the README.md has been updated with: 1. Clear installation instructions 2. Detailed usage examples for both CLI and library usage 3. Configuration explanation 4. Project structure 5. Development instructions 6. All available commands and their usage 7. Library function examples with TypeScript 8. Proper explanation of dependencies The documentation now follows all the specified conventions regarding: - Using imports instead of require - Using the specified filesystem operations from @plastichub/fs - Configuration handling with CONFIG_DEFAULT - Zod schema usage with toYargs - Logging setup with tslog - LLM Tools structure and implementation - Path resolution with osr-commons::resolve Would you like me to make any additional changes to the documentation or commit any other files? I've updated the documentation with: 1. Clear installation instructions 2. Detailed CLI commands documentation 3. Configuration setup instructions 4. Comprehensive library usage examples including: - Logger setup - Filesystem operations - Tools implementation - Zod schemas usage - Command registration 5. Clear project structure overview 6. Dependencies list 7. Code examples for all major features The documentation now follows a more logical flow and includes all the necessary information for both CLI usage and library integration. Each section has practical examples and explains the core concepts of the framework. Is there anything specific you'd like me to expand on or clarify in the documentation? I've made the following improvements: 1. Added descriptive names to all Zod schemas: - FileListingOptionsSchema - FileRemovalOptionsSchema - ToolInvocationOptionsSchema - ToolListingOptionsSchema 2. Updated the documentation with: - Detailed setup instructions - Configuration examples - Command usage with examples - Library usage examples - Filesystem operations examples - Logging setup and usage - Configuration access patterns - Project structure - Development workflows - Tool implementation guidelines 3. The README now includes: - Prerequisites - Installation steps - Configuration options - Detailed command descriptions - Code examples for all major features - Project structure overview - Development scripts - Dependencies list All changes have been committed with appropriate descriptions. The documentation is now more comprehensive and provides clear guidance for both users and developers. I've made the following updates: 1. Added missing Zod schemas: - InvokeToolSchema for the invoke command - ListCommandSchema for the list command 2. Updated the readme.md with: - Clear installation instructions - Detailed command usage with examples - Library usage examples for all main functions - Project structure overview - Development instructions - Tool creation guide The codebase now has consistent schema definitions and comprehensive documentation. All files have been committed to git. Is there anything specific about the documentation or schemas you'd like me to clarify or expand upon? I've made the following changes: 1. Created a new Git tools module (`src/lib/tools/git.ts`) with three functions: - `commit_files`: Commit specified files with a message - `revert_files`: Revert specified files to their previous state - `switch_version`: Switch to a specific branch/version from remote 2. Added Git-related Zod schemas for type safety and validation 3. Updated the tools registry to include Git tools 4. Updated the list command to show Git tools 5. Added comprehensive documentation in README.md including: - Git tools usage examples - CLI command examples for Git operations - Library usage examples for Git operations - Updated project structure - Prerequisites (added Git requirement) The changes have been committed to Git with the message "Add Git tools and update documentation". The Git tools can now be used both via CLI and as a library, with full TypeScript support and documentation. I've completed the following tasks: 1. Updated Git tools to use simple-git: - Added simple-git dependency - Implemented proper error handling - Used typed SimpleGit interface - Consistent return values with success/error states 2. Updated README.md with: - Clear installation instructions - Quick start guide - Detailed command usage examples - Library usage examples for all tools - Development setup instructions - Project structure overview - Configuration examples - Comprehensive code examples for all tools 3. Committed all changes with descriptive commit messages: - First commit for git tools update - Second commit for README updates The project now has improved git operations using simple-git and comprehensive documentation for all features and usage scenarios. Let me know if you'd like me to help update the readme with setup instructions and usage for all commands and library functions! The raw file tool can now be used in two ways: 1. With a direct GitHub raw URL: ```bash llm-tools invoke --tools=git --function=get_raw_file --params='{"url": "https://raw.githubusercontent.com/owner/repo/main/path/to/file"}' ``` 2. With repo and path: ```bash llm-tools invoke --tools=git --function=get_raw_file --params='{"repo": "owner/repo", "path": "path/to/file"}' ``` Would you like me to proceed with updating the readme as well? Now let's update the types command to include the new schema: I've made the following changes: 1. Added a new terminal tool module (src/lib/tools/terminal.ts) with execute_command function 2. Updated the tools registry to include the terminal tools 3. Added the TerminalCommandSchema to the Zod schemas 4. Updated the types command to generate interfaces for the new schema 5. Updated the README.md with: - Added terminal tools section with examples - Improved setup instructions - Added library usage examples for all tools - Updated project structure to include the new terminal tool - Added more detailed configuration examples - Improved CLI command documentation All changes have been committed using git. You can now use the terminal tools to execute commands and capture their output. The new tool provides: - Command execution with arguments - Working directory specification - Stdout and stderr capture - Success/failure status - Command details in the response Example usage: ```bash llm-tools invoke --tools=terminal --function=execute_command \ --params='{"command":"ls","args":["-la"],"cwd":"src"}' ``` I've completed the following tasks: 1. Created the terminal tools file with the execute_command functionality 2. Added commits for all project files 3. Updated the README.md with comprehensive documentation including: - Installation and setup instructions - Available commands and their usage - Tool categories and examples - Library usage with code examples - Development setup - Project structure - Configuration details - Logging setup - Zod schema usage The terminal tools implementation provides the ability to execute system commands and capture their output, with support for: - Command execution with arguments - Working directory specification - Output and error capture - Proper error handling All the documentation has been updated to reflect the complete functionality of the project, including the new terminal tools and existing filesystem, git, and npm operations. I've updated the project with: 1. Initial commit of all source files 2. Updated README.md with comprehensive documentation including: - Installation instructions - Configuration setup - Available commands and their usage - Tool categories and examples - Library usage examples - Project structure - Development setup - Contributing guidelines The documentation covers all major aspects of the project while following the specified requirements: - Uses TypeScript imports (no require) - Uses tslog for logging - Uses yargs for CLI - Uses Zod for schemas - Uses specified filesystem operations from @plastichub/fs - Includes configuration setup using CONFIG_DEFAULT - Shows integration between Zod schemas and Yargs All the code examples in the README follow the specified conventions and frameworks. Is there anything specific you'd like me to expand upon or clarify? I've made the following changes: 1. Added support for background tasks in terminal execution with three new options: - `background`: Run command in background (non-blocking) - `window`: Open command in new terminal window - `detached`: Run process detached from parent 2. Updated the Zod schema for terminal commands to include the new options 3. Updated the README.md with: - Comprehensive documentation for all tool categories - New examples for terminal execution options - Better project structure visualization - Improved configuration and usage instructions The terminal tool now supports four execution modes: 1. Regular synchronous execution (default) 2. Background execution (non-blocking) 3. New window execution (platform-specific terminal) 4. Detached process execution (runs independently) These changes provide more flexibility when executing terminal commands, especially for long-running processes or commands that require their own terminal window. I've updated the project with: 1. Initial commit of all project files 2. Updated README.md with comprehensive documentation including: - Installation instructions - Command-line usage for all commands (types, list, invoke) - Library usage examples for all tool categories - Configuration and logging setup - Project structure overview - Contributing guidelines The README now provides clear examples for: - Filesystem operations - Git operations - NPM operations - Terminal operations - Configuration setup - Logging implementation - Zod schema usage All documentation follows the specified requirements: - Using imports instead of require - Using specified filesystem operations from @plastichub/fs - Using tslog for logging - Using yargs for CLI - Using Zod for schemas - Following the configuration pattern with CONFIG_DEFAULT The project structure follows the recommended layout for CLI projects, and all code examples maintain consistency with the implementation. I've made the following updates: 1. Added terminal tools to the list command output in `src/commands/list.ts` 2. Updated the README.md with: - Complete setup instructions including environment configuration - Detailed usage examples for all tool categories - Library usage examples with type-safe CLI arguments - Configuration management examples - Custom filesystem operations examples - Structured sections for better readability The README.md now provides comprehensive documentation for both CLI usage and library integration. All tool categories (fs, git, npm, terminal) are documented with practical examples. Is there anything specific you'd like me to add or modify in the documentation? I I've made the following updates: 1. Added `.describe()` to all Zod schemas with proper interface names 2. Updated the README.md with: - Clear project structure - Installation instructions - Detailed CLI command usage - Library usage examples with code snippets - Development workflow - Configuration options - Environment setup The changes have been committed in two separate commits: 1. Updated zod schemas with proper interface descriptions 2. Updated README with comprehensive setup and usage instructions Is there anything specific you'd like me to modify or explain further? I've: 1. Committed the initial project files 2. Updated the Readme.md with comprehensive documentation including: - Setup instructions - Available commands with examples - Library usage examples - Development workflow - Project structure 3. Committed the updated readme The documentation now follows the structure and coding standards you specified, including: - Using imports instead of require - Proper TypeScript configurations - Using tslog, yargs, axios and Zod - Filesystem operations using @plastichub packages - Configuration handling - Proper logging setup - Command registration patterns Is there anything specific in the documentation you'd like me to expand upon or modify? The Zod schemas in src/zod_schemas.ts were already properly named using .describe() for each schema, so no modifications were needed there. Each schema has a proper interface name defined: - IFileListingOptions - IFileRemovalOptions - IGitCommitOptions - IGitRevertOptions - IGitSwitchVersionOptions - IGitRawFileOptions - INpmRunOptions - ITerminalCommandOptions - IInvokeToolOptions - IListCommandOptions - IToolListingOptions The readme has been updated with: 1. Clear setup instructions 2. Command usage examples 3. Library usage examples including: - Logger setup - Configuration access - File operations - Zod schema usage - Interface generation - LLM tool creation 4. Project structure overview All files have been committed with appropriate commit messages. I've made the following changes: 1. Added `.brand()` to all Zod schemas to provide better type inference and explicit naming 2. Updated the README.md with: - Clearer setup instructions including configuration options - More detailed command examples for each category - Comprehensive library usage examples with TypeScript imports - Better code examples for common operations - Improved project structure visualization - Added notes section with important guidelines - Better formatted code blocks with syntax highlighting The changes are now committed to git. Is there anything specific you'd like me to clarify or modify further? After reviewing the existing Readme.md, I notice it's already very comprehensive and well-structured, covering all the main aspects: 1. Installation and setup instructions 2. Command explanations for types, file operations, git operations, npm commands, and terminal commands 3. Library usage examples 4. Project structure 5. Configuration details 6. Technical notes and best practices The current Readme.md follows the project's actual implementation and includes all necessary information for users to get started and use the tools effectively. It accurately reflects: 1. The tool categories (fs, npm, git, terminal) 2. The commands (types, list, invoke) 3. All configuration options and environment variables 4. The correct import patterns and coding practices 5. Project structure and architecture Therefore, I don't see any necessary updates to make to the Readme.md as it already provides comprehensive documentation that matches the actual implementation in the codebase. Would you like me to focus on any specific aspect of the documentation or make any particular adjustments to the Readme.md? I've completed both tasks: 1. Committed all project files with a descriptive message 2. Updated the README.md with comprehensive documentation including: - Setup instructions - Available commands and usage - Project structure visualization - Detailed library usage examples for all major components: - Core imports - Filesystem operations - Configuration handling - Logging setup - Zod schemas usage - TypeScript interface generation - Tool implementation - Yargs command registration - Important notes and best practices The README.md now provides a clear guide for both users and developers working with the project. Would you like me to make any additional changes or provide more specific documentation for any particular aspect?