cleanup kbot :)

This commit is contained in:
Code 2025-02-02 11:03:44 +01:00
parent 02ed67ec1c
commit 9671502428
15 changed files with 301 additions and 142 deletions

View File

@ -1,4 +1,4 @@
# @plastichub/code-bot
# @plastichub/kbot
AI-powered command-line tool for code modifications and project management that supports multiple AI models and routers.
@ -42,7 +42,7 @@ KBot supports both OpenRouter and OpenAI APIs. You'll need at least one of these
### Installation using Node NPM package manager
```bash
npm install -g @plastichub/code-bot
npm install -g @plastichub/kbot
```
## Configuration
@ -78,6 +78,9 @@ Create configuration at `$HOME/.osr/.config.json` (or export OSR_CONFIG with pat
"serpapi": {
"key": "your SerpAPI key (optional, used for web searches(places, google maps))"
},
"deepseek": {
"key": "your SerpAPI key (optional, used for web searches(places, google maps))"
},
}
```
@ -106,6 +109,28 @@ When creating content
- always add links
- when sending emails, always add 'Best regards, [Your Name]'
```
## Commands
### Prompt
```kbot "create Astro minimal boilerplate, use starlight theme. Install dependencies via NPM tool"```
### Fetch latest models
```kbot fetch```
### Print examples
```kbot examples```
### Print extended help
```kbot help-md```
### Initialize folder
```kbot init```
# Command Line Parameters
This document describes all available command line parameters.
@ -117,11 +142,18 @@ This document describes all available command line parameters.
| `path` | Target directory | `.` | No |
| `prompt` | The prompt. Supports file paths and environment variables | `./prompt.md` | No |
| `output` | Optional output path for modified files (Tool mode only) | - | No |
| `dst` | Optional destination path for the result, will substitute ${MODEL} and ${ROUTER} in the path. Used for "completion" mode | - | No |
| `dst` | Optional destination path for the result, will substitute ${MODEL} and ${ROUTER} in the path. | - | No |
| `model` | AI model to use for processing | `anthropic/claude-3.5-sonnet` | No |
| `router` | Router to use: openai or openrouter | `openrouter` | No |
| `mode` | Chat completion mode: "completion" (without tools) or "tools" | `tools` | No |
## Advanced Parameters
| Parameter | Description | Default | Required |
|-----------|-------------|---------|----------|
| `each` | Target directory | `.` | No |
| `dry` | Dry run - only write out parameters without making API calls | `false` | No |
## File Selection & Tools
| Parameter | Description | Default | Required |
@ -146,35 +178,7 @@ This document describes all available command line parameters.
| `logLevel` | Logging level for the application (0-4) | `2` | No |
| `logs` | Logging directory | `./.kbot` | No |
| `dump` | Create a script | - | No |
| `dry` | Dry run - only write out parameters without making API calls | `false` | No |
## Examples
```bash
# Basic usage with default parameters
kbot --prompt="What are the changes needed?"
# Specify model and router
kbot --model="gpt-4" --router="openai" --prompt="Analyze this code"
# Process specific files
kbot --include="src/*.ts" --include="package.json" --prompt="Check for security issues"
# Dry run with custom logging
kbot --dry=true --logLevel=4 --prompt="Test run"
```
## Environment Variables
Many path-based parameters support environment variables using the `${VARIABLE}` syntax:
- `${POLYMECH-ROOT}` - Root directory for Polymech
- `${OSR-ROOT}` - Root directory for OSR
Example:
```bash
kbot --profile="${POLYMECH-ROOT}/custom-profile.json"
```
# Working on Larger Directories

View File

@ -0,0 +1,208 @@
# @plastichub/kbot
AI-powered command-line tool for code modifications and project management that supports multiple AI models and routers.
## Overview
Code-bot is a powerful CLI tool that helps developers automate code modifications, handle project management tasks, and integrate with various AI models for intelligent code and content assistance.
## Quick Start
### Installation Steps
KBot requires Node.js to run. It's recommended to use Node.js version 18 or higher.
1. Visit the official [Node.js website](https://nodejs.org/)
2. Download the LTS (Long Term Support) version for your operating system
3. Follow the installation wizard
4. Verify installation by opening a terminal and running:
```bash
node --version
npm --version
```
### API Keys
KBot supports both OpenRouter and OpenAI APIs. You'll need at least one of these set up.
#### OpenRouter API (Recommended)
1. Visit [OpenRouter](https://openrouter.ai/)
2. Sign up for an account
3. Navigate to the API Keys section
4. Create a new API key
#### OpenAI API (Optional)
1. Go to [OpenAI's platform](https://platform.openai.com/)
2. Create an account or sign in
3. Navigate to API keys section
4. Create a new secret key
### Installation using Node NPM package manager
```bash
npm install -g @plastichub/kbot
```
## Configuration
### API Keys Setup
Create configuration at `$HOME/.osr/.config.json` (or export OSR_CONFIG with path to config.json):
```json
{
"openrouter": {
"key": "your-openrouter-key"
},
"openai": {
"key": "your-openai-key"
},
"email": {
"newsletter": {
"host": "host.org",
"port": 465,
"debug": true,
"transactionLog": true,
"auth": {
"user": "foo@bar.com",
"pass": "pass"
}
}
},
"google": {
"cse": "custom search engine id",
"api_key": "google custom search api key"
},
"serpapi": {
"key": "your SerpAPI key (optional, used for web searches(places, google maps))"
},
"deepseek": {
"key": "your SerpAPI key (optional, used for web searches(places, google maps))"
},
}
```
### Preferences Setup
Optionally, create `.kbot/preferences.md` in your project directory to customize AI interactions:
```markdown
## My Preferences
Gender : male
Location : New York, USA (eg: `send me all saunas next to me`)
Language : English
Occupation : software developer, Typescript
Age : 30+
## Contacts
My email address : example@email.com (eg: `send me latest hacker news`)
My wife's email address ("Anne") : example@email.com (eg: `send email to my wife, with latest local news')
## Content
When creating content
- always Markdown
- always add links
- when sending emails, always add 'Best regards, [Your Name]'
```
## Commands
### Prompt
```kbot "create Astro minimal boilerplate, use starlight theme. Install dependencies via NPM tool"```
### Fetch latest models
```kbot fetch```
### Print examples
```kbot examples```
### Print extended help
```kbot help-md```
### Initialize folder
```kbot init```
# Command Line Parameters
This document describes all available command line parameters.
## Core Parameters
| Parameter | Description | Default | Required |
|-----------|-------------|---------|----------|
| `path` | Target directory | `.` | No |
| `prompt` | The prompt. Supports file paths and environment variables | `./prompt.md` | No |
| `output` | Optional output path for modified files (Tool mode only) | - | No |
| `dst` | Optional destination path for the result, will substitute ${MODEL} and ${ROUTER} in the path. | - | No |
| `model` | AI model to use for processing | `anthropic/claude-3.5-sonnet` | No |
| `router` | Router to use: openai or openrouter | `openrouter` | No |
| `mode` | Chat completion mode: "completion" (without tools) or "tools" | `tools` | No |
## Advanced Parameters
| Parameter | Description | Default | Required |
|-----------|-------------|---------|----------|
| `each` | Target directory | `.` | No |
| `dry` | Dry run - only write out parameters without making API calls | `false` | No |
## File Selection & Tools
| Parameter | Description | Default | Required |
|-----------|-------------|---------|----------|
| `include` | Glob patterns to match files for processing. Supports multiple patterns, e.g. `--include=src/*.tsx,src/*.ts --include=package.json` | - | No |
| `disable` | Disable tools categories | `[]` | No |
| `disableTools` | List of specific tools to disable | `[]` | No |
## Configuration & Profiles
| Parameter | Description | Default | Required |
|-----------|-------------|---------|----------|
| `profile` | Path to profile for variables. Supports environment variables | `${POLYMECH-ROOT}/profile.json` | No |
| `env` | Environment (in profile) | `default` | No |
| `config` | Path to JSON configuration file (API keys). Supports environment variables | - | No |
| `preferences` | Path to preferences file (location, email, gender, etc). Supports environment variables | `./.kbot/preferences.md` | No |
## Debugging & Logging
| Parameter | Description | Default | Required |
|-----------|-------------|---------|----------|
| `logLevel` | Logging level for the application (0-4) | `2` | No |
| `logs` | Logging directory | `./.kbot` | No |
| `dump` | Create a script | - | No |
# Working on Larger Directories
Since LLMs (Large Language Models) and providers are limited to very small 'context windows', it's necessary to feed them with smaller chunks instead. This document explains how to process larger directories efficiently.
## Directory Processing Example
Here's an example of how to walk through files and process them:
```bash
osr-cli each --main='kbot \"read ${KEY} and translate to german, save in docs/language code/filename.md\" --include=\"${REL}\" --include=\".kbot/preferences.md\"' --list="./docs/*.md" --cwd=.
```
### Parameter Explanation
- `each`: Command to process multiple files iteratively
- `--main`: The main command (`kbot`) to execute for each file
- `--include=\"${REL}\"` instructs kbot to include the current selected path
- `--include=\".kbot/preferences.md\"` instructs kbot to include additional preferences about the task (eg: translation specifics)
- `--list`: Specifies the file pattern to match
- Supports include patterns (e.g., `"./docs/*.md"`)
- `--cwd`: Sets the current working directory for the command execution. Default is the current directory (`.`)
**Note** requires `@plastichub/osr-cli-commons` to be installed globally:
```bash
npm i -g @plastichub/osr-cli-commons
```

File diff suppressed because one or more lines are too long

View File

@ -1,12 +1,12 @@
{
"name": "@plastichub/kbot",
"version": "1.1.4",
"version": "1.1.9",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@plastichub/kbot",
"version": "1.1.4",
"version": "1.1.9",
"license": "ISC",
"dependencies": {
"node-emoji": "^2.2.0"

View File

@ -1,6 +1,6 @@
{
"name": "@plastichub/kbot",
"version": "1.1.8",
"version": "1.1.9",
"main": "main_node.js",
"author": "",
"license": "ISC",

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,12 @@
## Resources
### Providers
- https://fireworks.ai/models/fireworks/stable-diffusion-xl-1024-v1-0
- https://huggingface.co/docs/huggingface.js/en/inference/README (JS SDK & Demos)
### models
- Background removal : https://huggingface.co/spaces/briaai/BRIA-RMBG-1.4

View File

@ -1,4 +1,4 @@
# @plastichub/code-bot
# @plastichub/kbot
AI-powered command-line tool for code modifications and project management that supports multiple AI models and routers.
@ -42,7 +42,7 @@ KBot supports both OpenRouter and OpenAI APIs. You'll need at least one of these
### Installation using Node NPM package manager
```bash
npm install -g @plastichub/code-bot
npm install -g @plastichub/kbot
```
## Configuration
@ -78,6 +78,9 @@ Create configuration at `$HOME/.osr/.config.json` (or export OSR_CONFIG with pat
"serpapi": {
"key": "your SerpAPI key (optional, used for web searches(places, google maps))"
},
"deepseek": {
"key": "your SerpAPI key (optional, used for web searches(places, google maps))"
},
}
```

View File

@ -0,0 +1,21 @@
## Commands
### Prompt
```kbot "create Astro minimal boilerplate, use starlight theme. Install dependencies via NPM tool"```
### Fetch latest models
```kbot fetch```
### Print examples
```kbot examples```
### Print extended help
```kbot help-md```
### Initialize folder
```kbot init```

View File

@ -1,18 +0,0 @@
## CLI
- [ ] run
- [ ] each
## Lib
- [ ] run
## Tool
- [ ] run
## API
- [ ] run

View File

@ -1,3 +1,4 @@
# CLI Examples
## Basic Commands
@ -22,13 +23,6 @@ kbot "Add unit tests for src/commands/*" --include="./src/commands/*.ts"
```
### View Logs
```bash
# View modification history
kbot log .
```
### Node.js API Projects
```bash
@ -142,4 +136,3 @@ cat my-prompt.md | kbot
# Specifying a file
kbot my-prompt.md
```

View File

@ -1,3 +1,4 @@
# Command Line Parameters
This document describes all available command line parameters.
@ -9,11 +10,18 @@ This document describes all available command line parameters.
| `path` | Target directory | `.` | No |
| `prompt` | The prompt. Supports file paths and environment variables | `./prompt.md` | No |
| `output` | Optional output path for modified files (Tool mode only) | - | No |
| `dst` | Optional destination path for the result, will substitute ${MODEL} and ${ROUTER} in the path. Used for "completion" mode | - | No |
| `dst` | Optional destination path for the result, will substitute ${MODEL} and ${ROUTER} in the path. | - | No |
| `model` | AI model to use for processing | `anthropic/claude-3.5-sonnet` | No |
| `router` | Router to use: openai or openrouter | `openrouter` | No |
| `mode` | Chat completion mode: "completion" (without tools) or "tools" | `tools` | No |
## Advanced Parameters
| Parameter | Description | Default | Required |
|-----------|-------------|---------|----------|
| `each` | Target directory | `.` | No |
| `dry` | Dry run - only write out parameters without making API calls | `false` | No |
## File Selection & Tools
| Parameter | Description | Default | Required |
@ -38,32 +46,4 @@ This document describes all available command line parameters.
| `logLevel` | Logging level for the application (0-4) | `2` | No |
| `logs` | Logging directory | `./.kbot` | No |
| `dump` | Create a script | - | No |
| `dry` | Dry run - only write out parameters without making API calls | `false` | No |
## Examples
```bash
# Basic usage with default parameters
kbot --prompt="What are the changes needed?"
# Specify model and router
kbot --model="gpt-4" --router="openai" --prompt="Analyze this code"
# Process specific files
kbot --include="src/*.ts" --include="package.json" --prompt="Check for security issues"
# Dry run with custom logging
kbot --dry=true --logLevel=4 --prompt="Test run"
```
## Environment Variables
Many path-based parameters support environment variables using the `${VARIABLE}` syntax:
- `${POLYMECH-ROOT}` - Root directory for Polymech
- `${OSR-ROOT}` - Root directory for OSR
Example:
```bash
kbot --profile="${POLYMECH-ROOT}/custom-profile.json"
```

View File

@ -1,49 +0,0 @@
# KBot Configuration Parameters
## Core Configuration
| Parameter | Type | Default | Description |
| --------- | ---- | ------- | ----------- |
| mode | enum (completion, tools, assistant) | tools | Chat completion mode: <br>- 'completion': no tool support, use --dst to save output <br>- 'tools': allows tools usage <br>- 'assistant': supports documents (PDF, DOCX, etc.) |
| model | string | - | AI model to use for processing |
| router | string | openrouter | Router to use: openai, openrouter or deepseek |
| api_key | string | - | Explicit API key to use |
| baseURL | string | - | Base URL for the API |
## Paths & Files
| Parameter | Type | Default | Description |
| --------- | ---- | ------- | ----------- |
| path | string | . | Target directory |
| prompt | string | ./prompt.md | The prompt. Supports file paths and env variables |
| output | string | - | Optional output path for modified files (Tool mode only) |
| dst | string | - | Optional destination path for the result |
| preferences | string | ./.kbot/preferences.md | Path to preferences file |
| logs | string | ./.kbot | Logging directory |
| config | string | - | Path to JSON configuration file |
## Tools & Filters
| Parameter | Type | Default | Description |
| --------- | ---- | ------- | ----------- |
| tools | string[] | [defaultTools] | List of tools to use |
| disable | string[] | [] | Disable tools categories |
| disableTools | string[] | [] | List of specific tools to disable |
| filters | string[] | '' | Filters to apply to the output |
## Other Options
| Parameter | Type | Default | Description |
| --------- | ---- | ------- | ----------- |
| env | string | default | Environment (in profile) |
| logLevel | number | 2 | Logging level for the application |
| dump | string | - | Create a script |
| variables | Record<string, string> | {} | Variables to use |
| dry | boolean | false | Dry run - only write out parameters |
## File Selection
| Parameter | Type | Default | Description |
| --------- | ---- | ------- | ----------- |
| each | string | - | Glob pattern to run for each matching file |
| include | string[] | - | Comma separated glob patterns or paths |

View File

@ -1,3 +1,6 @@
npm run webpack
sh scripts/update-readme.sh
cp README.md dist/README.md
cd dist
npm version patch
npm publish

View File

@ -1,3 +1,5 @@
cat ./docs_/README.md > ./README.md
cat ./docs_/commands.md >> ./README.md
cat ./docs_/parameters.md >> ./README.md
cat ./docs_/advanced.md >> ./README.md