maintainence love:)
This commit is contained in:
parent
d4712949be
commit
50d9c8d6da
@ -162,6 +162,8 @@ This document describes the command line parameters available for `kbot`.
|
||||
|-----------|-------------|---------|----------|
|
||||
| `path` | Target directory for local file operations or context. | `.` | No |
|
||||
| `include` | Specify input files or content. Accepts comma-separated glob patterns (e.g., `src/**/*.ts`), file paths, directory paths, or **web URLs** (e.g., `https://example.com/page`). | `[]` | No |
|
||||
| `exclude` | Comma-separated glob patterns or paths to exclude from processing (e.g., `src/**/*.test.ts,temp/`). | `[]` | No |
|
||||
| `globExtension` | Specify a glob extension behavior to find related files. Available presets: `match-cpp`. Also accepts a custom glob pattern with variables like `${SRC_DIR}`, `${SRC_NAME}`, `${SRC_EXT}` (e.g., `"${SRC_DIR}/${SRC_NAME}*.h"` to find headers for a .cpp file). | - | No |
|
||||
| `query` | JSONPath query to extract specific data from input objects (often used with structured input files). | `null` | No |
|
||||
|
||||
## Output & Formatting
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"timestamp": 1749015961186,
|
||||
"timestamp": 1749038292949,
|
||||
"models": [
|
||||
{
|
||||
"id": "gpt-4-0613",
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"timestamp": 1749015961310,
|
||||
"timestamp": 1749038293088,
|
||||
"models": [
|
||||
{
|
||||
"id": "deepseek/deepseek-r1-distill-qwen-7b",
|
||||
@ -11428,8 +11428,8 @@
|
||||
"instruct_type": "mistral"
|
||||
},
|
||||
"pricing": {
|
||||
"prompt": "0.00000002",
|
||||
"completion": "0.00000007",
|
||||
"prompt": "0.00000001",
|
||||
"completion": "0.00000006",
|
||||
"request": "0",
|
||||
"image": "0",
|
||||
"web_search": "0",
|
||||
@ -11437,7 +11437,7 @@
|
||||
},
|
||||
"top_provider": {
|
||||
"context_length": 131072,
|
||||
"max_completion_tokens": 16384,
|
||||
"max_completion_tokens": 131072,
|
||||
"is_moderated": false
|
||||
},
|
||||
"per_request_limits": null,
|
||||
|
||||
File diff suppressed because one or more lines are too long
4
packages/kbot/dist-in/zod_types.d.ts
vendored
4
packages/kbot/dist-in/zod_types.d.ts
vendored
@ -475,9 +475,9 @@ export interface IKBotOptions {
|
||||
Used only in completion mode and a given output file specified with --dst.
|
||||
It unwraps by default any code or data in Markdown.
|
||||
Choices:
|
||||
JSON,JSONUnescape,JSONPretty,AlphaSort,code,JSONParse,trim
|
||||
JSON,JSONUnescape,JSONPretty,AlphaSort,code,JSONParse,trim,markdown
|
||||
*/
|
||||
filters?: (string | ("JSON" | "JSONUnescape" | "JSONPretty" | "AlphaSort" | "code" | "JSONParse" | "trim")[] | string[] | ((...args_0: unknown[]) => unknown)[]);
|
||||
filters?: (string | ("JSON" | "JSONUnescape" | "JSONPretty" | "AlphaSort" | "code" | "JSONParse" | "trim" | "markdown")[] | string[] | ((...args_0: unknown[]) => unknown)[]);
|
||||
/** JSONPath query to be used to transform input objects */
|
||||
query?: (string | null);
|
||||
/** Dry run - only write out parameters without making API calls */
|
||||
|
||||
2
packages/kbot/dist/README.md
vendored
2
packages/kbot/dist/README.md
vendored
@ -162,6 +162,8 @@ This document describes the command line parameters available for `kbot`.
|
||||
|-----------|-------------|---------|----------|
|
||||
| `path` | Target directory for local file operations or context. | `.` | No |
|
||||
| `include` | Specify input files or content. Accepts comma-separated glob patterns (e.g., `src/**/*.ts`), file paths, directory paths, or **web URLs** (e.g., `https://example.com/page`). | `[]` | No |
|
||||
| `exclude` | Comma-separated glob patterns or paths to exclude from processing (e.g., `src/**/*.test.ts,temp/`). | `[]` | No |
|
||||
| `globExtension` | Specify a glob extension behavior to find related files. Available presets: `match-cpp`. Also accepts a custom glob pattern with variables like `${SRC_DIR}`, `${SRC_NAME}`, `${SRC_EXT}` (e.g., `"${SRC_DIR}/${SRC_NAME}*.h"` to find headers for a .cpp file). | - | No |
|
||||
| `query` | JSONPath query to extract specific data from input objects (often used with structured input files). | `null` | No |
|
||||
|
||||
## Output & Formatting
|
||||
|
||||
241
packages/kbot/dist/main_node.js
vendored
241
packages/kbot/dist/main_node.js
vendored
File diff suppressed because one or more lines are too long
4
packages/kbot/dist/package-lock.json
generated
vendored
4
packages/kbot/dist/package-lock.json
generated
vendored
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@plastichub/kbot",
|
||||
"version": "1.1.38",
|
||||
"version": "1.1.39",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@plastichub/kbot",
|
||||
"version": "1.1.38",
|
||||
"version": "1.1.39",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"node-emoji": "^2.2.0"
|
||||
|
||||
2
packages/kbot/dist/package.json
vendored
2
packages/kbot/dist/package.json
vendored
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@plastichub/kbot",
|
||||
"version": "1.1.38",
|
||||
"version": "1.1.39",
|
||||
"main": "main_node.js",
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
|
||||
@ -146,3 +146,158 @@ kbot --disableTools "npm_install,file_save" "Analyze dependencies but do not ins
|
||||
## More Examples
|
||||
|
||||
For more in-depth examples demonstrating various features like custom tools, different modes, and advanced configurations, please explore the code within the `src/examples/` directory of this package.
|
||||
|
||||
## Using `--dst` to Specify Output File
|
||||
|
||||
The `--dst` parameter allows you to specify a destination file for the output, particularly useful in `completion` or `assistant` mode. You can use variables like `${MODEL_NAME}` and `${ROUTER}` in the filename.
|
||||
|
||||
```bash
|
||||
# Summarize a document and save it to a specific file
|
||||
kbot --prompt "Summarize the key points of this document." \
|
||||
--include "./project_report.txt" \
|
||||
--dst "./summaries/report_summary.md" \
|
||||
--mode "completion"
|
||||
|
||||
# Generate code and save it with model name in the filename
|
||||
kbot --prompt "Write a Python function to calculate factorial." \
|
||||
--dst "./output_code/${MODEL_NAME}_factorial.py" \
|
||||
--model "openai/gpt-4o" \
|
||||
--mode "completion"
|
||||
```
|
||||
|
||||
## Excluding Files with `--exclude`
|
||||
|
||||
The `--exclude` parameter helps you filter out files or directories that you don't want `kbot` to process, even if they match the `--include` patterns.
|
||||
|
||||
```bash
|
||||
# Process all .ts files in the src directory, excluding test files and the node_modules directory
|
||||
kbot --prompt "Analyze code quality for all non-test TypeScript files." \
|
||||
--include "./src/**/*.ts" \
|
||||
--exclude "./src/**/*.test.ts,./src/**/*.spec.ts,node_modules/**" \
|
||||
--mode "tools"
|
||||
|
||||
# Include all markdown files but exclude those in a 'drafts' subdirectory
|
||||
kbot --prompt "Check for broken links in all published markdown files." \
|
||||
--include "./docs/**/*.md" \
|
||||
--exclude "./docs/drafts/*.md"
|
||||
```
|
||||
|
||||
## Finding Related Files with `--globExtension`
|
||||
|
||||
The `--globExtension` parameter is used to find files related to the input items (often specified with `--each` or `--include`). This is useful when a task requires context from associated files, like a C++ source file and its corresponding header.
|
||||
|
||||
It can take a preset (e.g., `match-cpp`) or a custom glob pattern using variables:
|
||||
* `${SRC_DIR}`: Directory of the source file.
|
||||
* `${SRC_NAME}`: Name of the source file without extension.
|
||||
* `${SRC_EXT}`: Extension of the source file.
|
||||
|
||||
```bash
|
||||
# For each .cpp file, find its corresponding .h file and generate documentation
|
||||
# (Assumes 'match-cpp' preset is defined to find .h files for .cpp inputs)
|
||||
kbot --each "./src/modules/*.cpp" \
|
||||
--globExtension "match-cpp" \
|
||||
--prompt "Generate documentation for ${ITEM} and its header file." \
|
||||
--dst "./docs/api/${ITEM}.md"
|
||||
|
||||
# For a given C source file, include its header file using a custom pattern
|
||||
# The --include parameter will be expanded by the globExtension logic to also find the .h file
|
||||
kbot --prompt "Analyze the C file ${ITEM} and its associated header." \
|
||||
--include "./src/utils.c" \
|
||||
--globExtension "'${SRC_DIR}/${SRC_NAME}.h'" \
|
||||
--dst "./analysis/utils_analysis.txt"
|
||||
```
|
||||
|
||||
This can be particularly powerful when combined with prompts that instruct the AI to consider all included files. The files found by `globExtension` are added to the context.
|
||||
|
||||
**Advanced Example: Generating Docs for C++ Headers and Sources**
|
||||
|
||||
Here's a more comprehensive example for generating documentation from C++ header files (`.h`). It iterates through each header file found by `--each`, uses `--globExtension="match-cpp"` to automatically include the corresponding `.cpp` source file in the context for the AI, and then generates documentation based on a prompt script.
|
||||
|
||||
The output is saved to the `./docs-c/` directory, with each file named after the original header's base name (e.g., `utils.h` becomes `utils.md`).
|
||||
|
||||
Key features in this example:
|
||||
* `--each="./src/*.h"`: Processes each header file in the `src` directory.
|
||||
* `--globExtension="match-cpp"`: For each `.h` file, it finds and includes the corresponding `.cpp` file.
|
||||
* `--mode="completion"` and `--dst='./docs-c/${SRC_NAME}.md'`: This combination ensures that if a documentation file for a header already exists at the destination, `kbot` will skip regenerating it, effectively "skipping existing files." The `${SRC_NAME}` variable refers to the base name of the header file.
|
||||
* `--prompt=./scripts/docs-c.md`: Uses an external markdown file as the prompt.
|
||||
* `--filters=markdown`: Applies a markdown filter to the output.
|
||||
* `--exclude='./docs-c/${SRC_NAME}*.md'`: This pattern prevents any existing markdown documentation files in the output directory from being accidentally treated as *input sources* during the process.
|
||||
|
||||
```bash
|
||||
kbot --model=anthropic/claude-3.7-sonnet \
|
||||
--prompt=./scripts/docs-c.md \
|
||||
--each=./src/*.h \
|
||||
--globExtension=match-cpp \
|
||||
--mode=completion \
|
||||
--filters=markdown \
|
||||
--preferences=none \
|
||||
--exclude='./docs-c/${SRC_NAME}*.md' \
|
||||
--dst='./docs-c/${SRC_NAME}.md'
|
||||
```
|
||||
|
||||
## Extracting Structured Data from Images (e.g., Modbus Manuals)
|
||||
|
||||
This example demonstrates how `kbot` can be used to iterate over a series of images (e.g., pages from a scanned PDF manual) and extract structured information into a single document. It leverages a multimodal model capable of understanding image content.
|
||||
|
||||
**Scenario:** Extract Modbus parameters and error codes from JPG images of a device manual and compile them into a Markdown file.
|
||||
|
||||
**Command:**
|
||||
|
||||
```bash
|
||||
kbot --model=google/gemini-2.5-pro-preview-03-25 \
|
||||
--prompt=./tests/pdf/prompt_manual.md \
|
||||
--each=./tests/pdf/780/*.jpg \
|
||||
--mode=completion --preferences=none \
|
||||
--dst=./tests/pdf/sako_manual.md \
|
||||
--filters=code --append=concat
|
||||
```
|
||||
|
||||
**Key Features Illustrated:**
|
||||
|
||||
* `--model=google/gemini-2.5-pro-preview-03-25`: Specifies a multimodal model capable of processing images.
|
||||
* `--prompt=./tests/pdf/prompt_manual.md`: Uses an external file for a detailed prompt. The content of this prompt is crucial for guiding the AI.
|
||||
* `--each=./tests/pdf/780/*.jpg`: Iterates over all JPG files in the specified directory.
|
||||
* `--mode=completion`: The task is a direct completion based on the prompt and each image.
|
||||
* `--dst=./tests/pdf/sako_manual.md`: All extracted information will be saved to this file.
|
||||
* `--append=concat`: As `kbot` processes each image (`${ITEM}` from `--each`), the output generated for that image is appended to the `sako_manual.md` file. This is useful for building a cumulative document from multiple sources.
|
||||
* `--filters=code`: This filter can help clean the output, for instance, by removing potential Markdown code fences if the model wraps its entire response in them, ensuring the content is directly usable.
|
||||
* `--preferences=none`: Ensures no external user preferences interfere with the prompt.
|
||||
|
||||
**Content of the Prompt (`./tests/pdf/prompt_manual.md`):**
|
||||
|
||||
```markdown
|
||||
Extract all parameters, as Markdown tables,
|
||||
|
||||
return "Skipping Number Page : Nothing found" if nothing has been found, otherwise use this layout and structure (only valid Markdown!!) :
|
||||
|
||||
## Parameters (if provided)
|
||||
|
||||
### Columns
|
||||
|
||||
- parameter
|
||||
- description
|
||||
- if provided, parameter group
|
||||
- range
|
||||
- default
|
||||
- Dont comment or explain, just return Markdown
|
||||
- insert new lines before and after headers
|
||||
- insert a descriptive chapter name, header level 3 with the page number
|
||||
|
||||
## Error Codes (if provided)
|
||||
|
||||
### Columns
|
||||
|
||||
- code
|
||||
- description
|
||||
- if provided, parameter group
|
||||
- Dont comment or explain, just return Markdown
|
||||
- insert new lines before and after headers
|
||||
- insert a descriptive chapter name, header level 3 with the page number
|
||||
```
|
||||
|
||||
This detailed prompt instructs the AI on:
|
||||
* The specific information to look for (parameters, error codes).
|
||||
* The desired output format (Markdown tables).
|
||||
* The exact column names for the tables.
|
||||
* How to handle cases where no information is found on a page.
|
||||
* Formatting details like new lines and header levels, including dynamic information like page numbers (which the AI would infer or be instructed to extract if page numbers are visible in the images and the prompt is adjusted accordingly for `${ITEM}`).
|
||||
|
||||
@ -19,6 +19,8 @@ This document describes the command line parameters available for `kbot`.
|
||||
|-----------|-------------|---------|----------|
|
||||
| `path` | Target directory for local file operations or context. | `.` | No |
|
||||
| `include` | Specify input files or content. Accepts comma-separated glob patterns (e.g., `src/**/*.ts`), file paths, directory paths, or **web URLs** (e.g., `https://example.com/page`). | `[]` | No |
|
||||
| `exclude` | Comma-separated glob patterns or paths to exclude from processing (e.g., `src/**/*.test.ts,temp/`). | `[]` | No |
|
||||
| `globExtension` | Specify a glob extension behavior to find related files. Available presets: `match-cpp`. Also accepts a custom glob pattern with variables like `${SRC_DIR}`, `${SRC_NAME}`, `${SRC_EXT}` (e.g., `"${SRC_DIR}/${SRC_NAME}*.h"` to find headers for a .cpp file). | - | No |
|
||||
| `query` | JSONPath query to extract specific data from input objects (often used with structured input files). | `null` | No |
|
||||
|
||||
## Output & Formatting
|
||||
|
||||
@ -195,7 +195,8 @@
|
||||
"AlphaSort",
|
||||
"code",
|
||||
"JSONParse",
|
||||
"trim"
|
||||
"trim",
|
||||
"markdown"
|
||||
]
|
||||
}
|
||||
},
|
||||
@ -210,7 +211,7 @@
|
||||
}
|
||||
],
|
||||
"default": "",
|
||||
"description": "List of filters to apply to the output.\n Used only in completion mode and a given output file specified with --dst. \n It unwraps by default any code or data in Markdown. \n Choices:\n\tJSON,JSONUnescape,JSONPretty,AlphaSort,code,JSONParse,trim\n"
|
||||
"description": "List of filters to apply to the output.\n Used only in completion mode and a given output file specified with --dst. \n It unwraps by default any code or data in Markdown. \n Choices:\n\tJSON,JSONUnescape,JSONPretty,AlphaSort,code,JSONParse,trim,markdown\n"
|
||||
},
|
||||
"query": {
|
||||
"type": [
|
||||
|
||||
@ -133,7 +133,7 @@
|
||||
"ui:placeholder": {}
|
||||
},
|
||||
"filters": {
|
||||
"ui:description": "List of filters to apply to the output.\n Used only in completion mode and a given output file specified with --dst. \n It unwraps by default any code or data in Markdown. \n Choices:\n\tJSON,JSONUnescape,JSONPretty,AlphaSort,code,JSONParse,trim\n",
|
||||
"ui:description": "List of filters to apply to the output.\n Used only in completion mode and a given output file specified with --dst. \n It unwraps by default any code or data in Markdown. \n Choices:\n\tJSON,JSONUnescape,JSONPretty,AlphaSort,code,JSONParse,trim,markdown\n",
|
||||
"ui:title": "Filters",
|
||||
"ui:placeholder": []
|
||||
},
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
kbotd modify \
|
||||
--prompt="./.kbot/docs.md" \
|
||||
--include="./src/commands/run.ts" \
|
||||
--include="./src/zod_schema.ts" \
|
||||
--logLevel=2
|
||||
|
||||
|
||||
@ -475,9 +475,9 @@ export interface IKBotOptions {
|
||||
Used only in completion mode and a given output file specified with --dst.
|
||||
It unwraps by default any code or data in Markdown.
|
||||
Choices:
|
||||
JSON,JSONUnescape,JSONPretty,AlphaSort,code,JSONParse,trim
|
||||
JSON,JSONUnescape,JSONPretty,AlphaSort,code,JSONParse,trim,markdown
|
||||
*/
|
||||
filters?: (string | ("JSON" | "JSONUnescape" | "JSONPretty" | "AlphaSort" | "code" | "JSONParse" | "trim")[] | string[] | ((...args_0: unknown[]) => unknown)[]);
|
||||
filters?: (string | ("JSON" | "JSONUnescape" | "JSONPretty" | "AlphaSort" | "code" | "JSONParse" | "trim" | "markdown")[] | string[] | ((...args_0: unknown[]) => unknown)[]);
|
||||
/** JSONPath query to be used to transform input objects */
|
||||
query?: (string | null);
|
||||
/** Dry run - only write out parameters without making API calls */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user