gaunt-sloth-assistant
Version:
> ⚠️ **`gaunt-sloth-assistant` has been renamed to [`gaunt-sloth`](https://www.npmjs.com/package/gaunt-sloth).** > The `1.5.x` series is the final release under the old name — active development continues under > the new package. To switch: > > ```bash >
60 lines • 2.97 kB
JavaScript
import { Command, Option } from 'commander';
import { askCommand } from '#src/commands/askCommand.js';
import { initCommand } from '#src/commands/initCommand.js';
import { reviewCommand } from '#src/commands/reviewCommand.js';
import { prCommand } from '#src/commands/prCommand.js';
import { chatCommand } from '#src/commands/chatCommand.js';
import { codeCommand } from '#src/commands/codeCommand.js';
import { apiCommand } from '#src/commands/apiCommand.js';
import { getCommand } from '#src/commands/getCommand.js';
import { argv, getSlothVersion, readStdin } from '@gaunt-sloth/core/utils/systemUtils.js';
import { coerceBooleanOrString } from '@gaunt-sloth/core/utils/consoleUtils.js';
const program = new Command();
program
.name('gsloth')
.description('Gaunt Sloth Assistant reviewing your PRs')
.version(getSlothVersion())
.option('--verbose', 'Set LangChain/LangGraph to verbose mode, ' +
'causing LangChain/LangGraph to log many details to the console. ' +
'Consider using debugLog from config.ts for less intrusive debug logging.')
.option('-c, --config <path>', 'Path to custom configuration file')
.option('-i, --identity-profile <identity>', 'Identity profile (separate config and prompts)')
.option('-w, --write-output-to-file <value>', 'Write output to file. Accepts true/false or a filename. Shortcuts: -wn or -w0 for false.')
.addOption(new Option('--nopipe').hideHelp(true));
const cliConfigOverrides = {};
// Parse global options before binding any commands
program.parseOptions(argv);
if (program.getOptionValue('verbose')) {
/**
* Set LangChain/LangGraph to verbose mode,
* causing LangChain/LangGraph to log many details to the console.
* debugLog from config.ts may be a less intrusive option.
*/
cliConfigOverrides.verbose = true;
}
if (program.getOptionValue('config')) {
// Set a custom config path
cliConfigOverrides.customConfigPath = program.getOptionValue('config');
}
if (program.getOptionValue('identityProfile')) {
cliConfigOverrides.identityProfile = program.getOptionValue('identityProfile');
}
const writeToFile = program.getOptionValue('writeOutputToFile');
// Commander does an interesting thing: if a shortcut like -w exists,
// everything after this shortcut without a space becomes the value.
// Examples: -wn comes with value 'n', -w0 => '0', -wreview.md => 'review.md'
const coerced = coerceBooleanOrString(writeToFile);
if (coerced !== undefined) {
cliConfigOverrides.writeOutputToFile = coerced;
}
// Initialize all commands - they will handle their own config loading
initCommand(program);
reviewCommand(program, cliConfigOverrides);
prCommand(program, cliConfigOverrides);
askCommand(program, cliConfigOverrides);
chatCommand(program, cliConfigOverrides);
codeCommand(program, cliConfigOverrides);
apiCommand(program, cliConfigOverrides);
getCommand(program, cliConfigOverrides);
await readStdin(program);
//# sourceMappingURL=cli.js.map