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 Default Description commandNamestring The name of the CLI command
paramsobject | Map <optional>
{} Raw parameters as an object or Map in the shape {parameterName: parameterValue}. A Map is preferred to guarantee parameter order; objects may have non-deterministic ordering.
- Since:
-
- 10.0.0
- 10.4.0 defaultCLIFunc now only accepts a raw parameters object
Returns:
Generated CLI command string
- Type
- string
Examples
const cmd = ChartIQRegistryAPI.defaultCLIFunc("symbol", { symbol: "AAPL" }); console.log(cmd); // 'symbol "AAPL"'const cmd = ChartIQRegistryAPI.defaultCLIFunc("periodicity", { periodicity: "1 Hour" }); console.log(cmd); // 'periodicity "1 Hour"'const cmd = ChartIQRegistryAPI.defaultCLIFunc("home", {}); console.log(cmd); // "home"// Using a Map for guaranteed parameter order const params = new Map([["first", "value1"], ["second", "value2"]]); const cmd = ChartIQRegistryAPI.defaultCLIFunc("myCmd", params); console.log(cmd); // 'myCmd "value1" "value2"' -
<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. Returns undefined when duplicate tool names are detected.
- Type
- object | undefined
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). Returns false when duplicate tool names are detected.
- Type
- string | boolean
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" });
