83 lines
1.9 KiB
JavaScript
83 lines
1.9 KiB
JavaScript
#!/usr/bin/env node
|
|
import yargs from 'yargs'
|
|
import { hideBin } from 'yargs/helpers'
|
|
import { toYargs } from '@polymech/commons'
|
|
import { createLogger } from '@polymech/log'
|
|
import { OptionsSchema, types } from './zod_schema.js'
|
|
|
|
import { IKBotTask } from '@polymech/ai-tools'
|
|
|
|
import helpCommand from './commands/help.js'
|
|
import { examples } from './commands/examples.js'
|
|
import { init } from './commands/init.js'
|
|
import { build } from './commands/build.js'
|
|
import { fetch } from './commands/fetch.js'
|
|
import { run } from './commands/run.js'
|
|
|
|
export const logger: any = createLogger('llm-tools')
|
|
|
|
const modify = async (argv: IKBotTask) => await run(argv as IKBotTask)
|
|
|
|
const yargOptions: any = {
|
|
onKey: ((_yargs, key, options) => {
|
|
switch (key) {
|
|
case 'prompt':
|
|
{
|
|
return _yargs.positional(key, options)
|
|
}
|
|
case 'include':
|
|
{
|
|
return _yargs.option(key, {...options, alias: key[0].toLowerCase()})
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
yargs(hideBin(process.argv))
|
|
.command(
|
|
'init',
|
|
'Initialize KBot configuration',
|
|
(yargs) => toYargs(yargs, OptionsSchema(), yargOptions),
|
|
init
|
|
)
|
|
.command(
|
|
'modify [prompt]',
|
|
'Modify an existing project',
|
|
(yargs) => toYargs(yargs, OptionsSchema(), yargOptions),
|
|
modify
|
|
)
|
|
.command(
|
|
'types',
|
|
'Generate types',
|
|
(yargs) => { },
|
|
(argv) => types()
|
|
)
|
|
.command(
|
|
'build',
|
|
'Build kbot essentials',
|
|
(yargs) => { },
|
|
(argv) => build()
|
|
)
|
|
.command(
|
|
'fetch',
|
|
"Fetch models, to $HOME/.kbot/",
|
|
(yargs) => { },
|
|
(argv) => fetch()
|
|
)
|
|
.command(
|
|
'help-md',
|
|
'Generate markdown help',
|
|
(yargs) => { },
|
|
helpCommand
|
|
)
|
|
.command(
|
|
'examples',
|
|
'Show examples',
|
|
(yargs) => { },
|
|
examples
|
|
)
|
|
.command(['modify [prompt]', '$0'], 'Default command modify',
|
|
(yargs) => toYargs(yargs, OptionsSchema(), yargOptions), modify)
|
|
.help()
|
|
//.wrap(yargs.terminalWidth() - 20)
|
|
.parse() |