new ChartIQRegistryAPI()
Methods
-
<static> _createCLIFunction(commandName)
-
Creates a CLI function bound to a specific command name. This method exists to avoid function-in-loop JSHint warnings.
Parameters:
Name Type Description commandNamestring The name of the command to bind
- Since:
-
10.0.0
Returns:
A function that will execute the CLI command with the bound command name
- Type
- function
-
<static> addCLIFunc(registry, commandName, entry)
-
Adds a new CLI command function to the provided registry. Note: do not pass an arrow function as
functo ensure properthiscontext.Parameters:
Name Type Description registryobject The registry to which the command will be added
commandNamestring The name of the CLI command
entryobject The command entry object.
Properties
Name Type Argument Description funcfunction The function that implements the CLI command.
manstring <optional>
The manpage description of the command.
optsstring <optional>
The getopts-style options string for the command.
usagestring <optional>
The usage string for the command.
aiobject <optional>
The AI configuration object for the command.
- Since:
-
10.0.0
Example
import { registry } from "./plugins/cli/registry.js"; ChartIQRegistryAPI.addCLIFunc(registry, "customCmd", function(){ this.log(`customCmd executed with option value: ${func.opts.v}`); this.log(`flag was ${func.opts.b ? '' : 'not'} set`); }, "Custom command example", "bv:", "customCmd [options]", { description: "Custom command for AI", parameters: [ { name: "b", type: "string", description: "A boolean flag", examples: ["-b"], required: false }, { name: "v", type: "string", description: "An option for the command", examples: ["-v value"], required: false } ], func: "cli" }); -
<static> defaultCLIFunc(commandName, params)
-
Default CLI command generator function. Takes all parameter values and joins them with the command name to create a CLI command string.
Parameters:
Name Type Argument Description commandNamestring The name of the CLI command
paramsstring <repeatable>
String parameters passed to the function
- Since:
-
10.0.0
Returns:
Generated CLI command string with all parameters joined by spaces
- Type
- string
Examples
const cmd = ChartIQRegistryAPI.defaultCLIFunc("type", "candle"); console.log(cmd); // "type candle"const cmd = ChartIQRegistryAPI.defaultCLIFunc("series", "-c", "MSFT"); console.log(cmd); // "series -c MSFT" -
<static> generateTools(registry)
-
Processes the CLI registry contents and generates executable tool definitions for AI systems. Extracts commands with AI configuration and creates tool objects containing descriptions, enhanced parameter definitions, and executable functions. Parameter descriptions are automatically enriched with enum values, format patterns, and examples when available. If ai.func is set to the string "cli",
defaultCLIFuncwill be used.Parameters:
Name Type Description registryobject The contents of the CLI registry
- Since:
-
10.0.0
Returns:
Generated tools object with command names as keys and tool configurations as values
- Type
- object
Example
const tools = ChartIQRegistryAPI.generateTools(cliRegistry); console.log(tools); // Output: { type: { description: "...", parameters: [...], func: function } } -
<static> writePrompt(registry [, options])
-
Processes the CLI registry contents and formats them as a structured prompt suitable for AI systems. Extracts commands with AI configuration, builds command syntax with parameter notation, and outputs either formatted text or JSON containing command descriptions and parameter details.
Parameters:
Name Type Argument Default Description registryobject The contents of the CLI registry
optionsobject <optional>
{} Configuration options for prompt generation
Properties
Name Type Argument Default Description customHeadingstring <optional>
Custom heading text instead of "List of ChartIQ Commands:"
outputFormatstring <optional>
"text" Output format: "text" or "json"
- Since:
-
10.0.0
Returns:
Formatted prompt string for AI consumption (text format) or JSON string (json format)
- Type
- string
Example
const prompt = ChartIQRegistryAPI.writePrompt(cliRegistry); console.log(prompt); // With custom heading const prompt = ChartIQRegistryAPI.writePrompt(cliRegistry, { customHeading: "Available Chart Commands:" }); // With JSON output const prompt = ChartIQRegistryAPI.writePrompt(cliRegistry, { outputFormat: "json" });
