@jasondark/proompt
Version:
CLI tool for running AI prompts with structure and repeatability
152 lines • 6.98 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.configCommand = void 0;
const command_utils_1 = require("@/core/command-utils");
const settings_1 = require("@/core/config/settings");
const schemas_1 = require("@/core/schemas");
// Custom handler for config command (no proompt template needed)
const configHandler = async (args) => {
const validatedArgs = schemas_1.configArgsSchema.parse(args);
const isGlobal = validatedArgs.global;
const isProject = validatedArgs.project;
if (!validatedArgs.setLlmCli && !validatedArgs.setOutputFormat) {
// Show current configuration with clear messaging
if (isGlobal) {
const globalMeta = (0, settings_1.readGlobalSettings)();
if (globalMeta.fileExists && globalMeta.settings) {
console.log(`Global configuration (from ${globalMeta.filePath}):`);
console.log(` LLM CLI: ${globalMeta.settings.llmCli}`);
console.log(` Output format: ${globalMeta.settings.outputFormat ? globalMeta.settings.outputFormat.join(', ') : globalMeta.settings.llmCli}`);
}
else {
console.log('No global configuration file found.');
console.log('Using built-in defaults:');
console.log(' LLM CLI: claude (default)');
console.log(' Output format: claude (default)');
console.log('');
console.log('Create global settings: proompt config --global --set-llm-cli <value>');
}
}
else if (isProject) {
const projectMeta = (0, settings_1.readProjectSettings)();
const globalMeta = (0, settings_1.readGlobalSettings)();
if (projectMeta.fileExists && projectMeta.settings) {
console.log(`Project configuration (from ${projectMeta.filePath}):`);
console.log(` LLM CLI: ${projectMeta.settings.llmCli}`);
console.log(` Output format: ${projectMeta.settings.outputFormat ? projectMeta.settings.outputFormat.join(', ') : projectMeta.settings.llmCli}`);
}
else {
console.log('No project configuration file found.');
console.log('Effective settings for this project:');
if (globalMeta.fileExists && globalMeta.settings) {
console.log(` LLM CLI: ${globalMeta.settings.llmCli} (from global settings)`);
console.log(` Output format: ${globalMeta.settings.outputFormat ? globalMeta.settings.outputFormat.join(', ') : globalMeta.settings.llmCli} (from global settings)`);
}
else {
console.log(' LLM CLI: claude (built-in default)');
console.log(' Output format: claude (built-in default)');
}
console.log('');
console.log('Create project settings: proompt config --project --set-llm-cli <value>');
}
}
return;
}
// Determine which settings to read/write
const currentMeta = isGlobal ? (0, settings_1.readGlobalSettings)() : (0, settings_1.readProjectSettings)();
const currentSettings = currentMeta.settings || { llmCli: 'claude' };
const newSettings = { ...currentSettings };
if (validatedArgs.setLlmCli) {
newSettings.llmCli = validatedArgs.setLlmCli;
console.log(`✓ LLM CLI set to: ${validatedArgs.setLlmCli}`);
}
if (validatedArgs.setOutputFormat) {
// Parse comma-separated format list and validate
const { outputFormatSchema } = await Promise.resolve().then(() => __importStar(require('@/core/schemas')));
const formatList = validatedArgs.setOutputFormat
.split(',')
.map((f) => f.trim());
const validatedFormats = outputFormatSchema.parse(formatList);
newSettings.outputFormat = validatedFormats;
console.log(`✓ Output format set to: ${validatedFormats.join(', ')}`);
}
// Write to appropriate settings file
if (isGlobal) {
(0, settings_1.writeGlobalSettings)(newSettings);
console.log(`✓ Global settings saved to: ${(0, settings_1.getGlobalSettingsPath)()}`);
}
else if (isProject) {
(0, settings_1.writeProjectSettings)(newSettings);
console.log(`✓ Project settings saved to: ${(0, settings_1.getProjectSettingsPath)()}`);
}
};
// Create and export the command module
exports.configCommand = (0, command_utils_1.createCommandModule)({
name: 'config',
description: 'Configure proompt settings (view or update)',
arguments: [
{
name: 'global',
description: 'Manage global settings (stored in home directory)',
required: false,
type: 'boolean',
alias: 'g',
},
{
name: 'project',
description: 'Manage project settings (stored in current directory)',
required: false,
type: 'boolean',
alias: 'p',
},
{
name: 'set-llm-cli',
description: 'Set the LLM CLI (claude|gemini)',
required: false,
type: 'string',
alias: 'L',
},
{
name: 'set-output-format',
description: 'Set output format (claude,gemini or any combination)',
required: false,
type: 'string',
alias: 'F',
},
],
}, schemas_1.configArgsSchema, '', // No proompt content needed
configHandler);
//# sourceMappingURL=index.js.map