build-in-public-bot
Version:
AI-powered CLI bot for automating build-in-public tweets with code screenshots
85 lines • 4.28 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.summaryCommand = void 0;
const commander_1 = require("commander");
const chalk_1 = __importDefault(require("chalk"));
const ora_1 = __importDefault(require("ora"));
const context_analyzer_1 = require("../services/context-analyzer");
const config_1 = require("../services/config");
const ai_1 = require("../services/ai");
const storage_1 = require("../services/storage");
const errors_1 = require("../utils/errors");
exports.summaryCommand = new commander_1.Command('summary')
.description('Generate a summary tweet of your recent coding session')
.option('-s, --save', 'Save as draft instead of posting')
.option('-c, --screenshot', 'Include a code screenshot from recent changes')
.action(async (options) => {
try {
const spinner = (0, ora_1.default)('Analyzing your coding session...').start();
const configService = config_1.ConfigService.getInstance();
const config = await configService.load();
const contextAnalyzer = context_analyzer_1.ContextAnalyzerService.getInstance();
const aiService = ai_1.AIService.getInstance();
const storageService = storage_1.StorageService.getInstance();
const context = await contextAnalyzer.analyzeCurrentContext();
spinner.text = 'Generating summary...';
let summaryMessage = `Summary of work on ${context.projectName}`;
if (context.recentChanges.length > 0) {
const fileCount = new Set(context.recentChanges.map(c => c.path)).size;
summaryMessage += `. Made changes to ${fileCount} files`;
}
if (context.uncommittedFiles.length > 0) {
summaryMessage += `. ${context.uncommittedFiles.length} files modified`;
}
if (context.lastCommitMessage) {
summaryMessage += `. Last commit: "${context.lastCommitMessage.split('\n')[0]}"`;
}
const tweet = await aiService.generateTweet({
message: summaryMessage,
includeScreenshot: options.screenshot
}, config);
spinner.succeed('Summary generated!');
console.log('\n' + chalk_1.default.cyan('📊 Session Summary:'));
console.log(` Project: ${chalk_1.default.white(context.projectName)}`);
console.log(` Branch: ${chalk_1.default.white(context.currentBranch)}`);
if (context.language) {
console.log(` Language: ${chalk_1.default.white(context.language)}`);
}
if (context.framework) {
console.log(` Framework: ${chalk_1.default.white(context.framework)}`);
}
console.log(` Recent changes: ${chalk_1.default.white(context.recentChanges.length)} files`);
console.log(` Uncommitted: ${chalk_1.default.white(context.uncommittedFiles.length)} files`);
if (context.recentChanges.length > 0) {
console.log('\n' + chalk_1.default.cyan('Recent files:'));
context.recentChanges.slice(0, 5).forEach(change => {
const icon = change.type === 'add' ? '✨' : change.type === 'change' ? '📝' : '🗑️';
console.log(` ${icon} ${chalk_1.default.dim(change.path)}`);
});
if (context.recentChanges.length > 5) {
console.log(` ${chalk_1.default.dim(`... and ${context.recentChanges.length - 5} more`)}`);
}
}
console.log('\n' + chalk_1.default.green('📱 Generated Tweet:'));
console.log(chalk_1.default.white(tweet));
if (options.save) {
await storageService.saveDraft({
id: `summary-${Date.now()}`,
text: tweet,
createdAt: new Date(),
includeScreenshot: options.screenshot
});
console.log('\n' + chalk_1.default.green('✅ Saved as draft'));
}
else {
console.log('\n' + chalk_1.default.dim('Use "bip post" to tweet this or add --save to save as draft'));
}
}
catch (error) {
(0, errors_1.handleError)(error);
}
});
//# sourceMappingURL=summary.js.map
;