TODO

Improve code

TODO

Rewrite code with correct style

TODO

Rewrite code with using idiomatic constructs

TODO

Simplify code

TODO

Explore alternatives

TODO

Write documentation

Hierarchy

  • HgAiCommandServiceImpl

Implements

Constructors

Properties

_bestOf: number
_client: OpenAiClient
_echo: boolean
_frequencyPenalty: number
_iterations: number
_language: string
_logProbs: number
_maxTokens: number
_model: string
_n: number
_presencePenalty: number
_stop: string
_suffix: string
_temperature: number
_topP: number
_user: string

Methods

  • Private

    Loop through arguments and if the argument exists on the file system, read it and return the content as the argument instead.

    Fixme

    Change to asynchronous

    Parameters

    • list: readonly string[]

    Returns Promise<readonly string[]>

  • Writes descriptions about code.

    Example describe('./keys.ts') will print out description about the code:

    This TypeScript code is an exported function called "keys" that takes two
    parameters, "value" and "isKey". The "value" parameter is of type "any"
    and the "isKey" parameter is of type "TestCallbackNonStandard". The
    function returns an array of type "T" which is a generic type that extends
    the type "keyof any".

    The function starts by checking if the "value" parameter is an array. If
    it is, it uses the "map" function to create an array of indexes from the
    "value" array. It then uses the "filter" function to filter out the
    indexes that pass the "isKey" test. The filtered indexes are then
    returned as an array of type "T".

    If the "value" parameter is an object, the function uses the
    "Reflect.ownKeys" function to get an array of all the keys of the object.
    It then uses the "filter" function to filter out the keys that pass the
    "isKey" test. The filtered keys are then returned as an array of type "T".

    If the "value" parameter is neither an array nor an object, the function
    returns an empty array of type "T".

    Parameters

    • args: readonly string[]

    Returns Promise<CommandExitStatus>

  • OpenAI edit action

    Example 1: edit(['Fix the spelling mistakes', 'What day of the wek is it?']) will print out "What day of the week is it?".

    Example 2: edit(['Write a function in python that calculates fibonacci']) will print out Python implementation of fibonacci function.

    Example 3: edit(['Rename the function to fib', 'def fibonacci(num): if num <= 1: return num else: return fib(num-1) + fib(num-2) print(fibonacci(10))']) will print out:

    def fib(num):
    if num <= 1:
    return num
    else:
    return fib(num-1) + fib(num-2)
    print(fib(10))

    Parameters

    • args: readonly string[]

    Returns Promise<CommandExitStatus>

  • The main command line handler.

    It is intended to be called when user calls hg ai ... with the remaining arguments as args option.

    Example 1: main(['completion', ...]) will call completion([...]) Example 2: main(['comp', ...]) will call completion([...]) Example 3: main(['c', ...]) will call completion([...]) Example 4: main(['edit', ...]) will call edit([...]) Example 5: main(['e', ...]) will call edit([...]) Example 6: main(['test', ...]) will call test([...]) Example 7: main(['t', ...]) will call test([...])

    Parameters

    • args: readonly string[]

    Returns Promise<CommandExitStatus>

  • Write test cases

    Example writeTests('./FooService.ts') will print out unit tests for the FooService written in TypeScript and Jest framework.

    Tests should look like:

    describe("Class", () => {

    describe("Method", () => {

    it('should ...', () => {
    // ... here test implementation ...
    });

    });

    });

    Parameters

    • args: readonly string[]

    Returns Promise<CommandExitStatus>

Generated using TypeDoc