ai-dev-diary
Version:
Intelligent development diary system for AI-assisted projects
131 lines ⢠4.71 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EntryBuilder = void 0;
const crypto_1 = require("crypto");
const inquirer_1 = __importDefault(require("inquirer"));
const chalk_1 = __importDefault(require("chalk"));
class EntryBuilder {
async build(options) {
const completeOptions = await this.completeOptions(options);
const entry = {
id: (0, crypto_1.randomUUID)(),
timestamp: new Date(),
type: completeOptions.type,
title: completeOptions.title,
content: completeOptions.description || '',
tags: completeOptions.tags || [],
metadata: {
author: completeOptions.author || 'Unknown',
aiAgent: completeOptions.aiAgent,
relatedFiles: completeOptions.relatedFiles,
correction: completeOptions.correction,
impact: completeOptions.impact,
},
};
return entry;
}
async createInteractive() {
console.log(chalk_1.default.blue('\nš Create New Diary Entry\n'));
const answers = await inquirer_1.default.prompt([
{
type: 'list',
name: 'type',
message: 'Entry type:',
choices: [
{ name: 'š Journey - Development progress', value: 'journey' },
{ name: 'š” Insight - Discovery or realization', value: 'insight' },
{ name: 'ā Mistake - Error and correction', value: 'mistake' },
{ name: 'šÆ Breakthrough - Major solution', value: 'breakthrough' },
{ name: 'š Context - Project state update', value: 'context' },
],
},
{
type: 'input',
name: 'title',
message: 'Title:',
validate: (input) => input.length > 0 || 'Title is required',
},
{
type: 'editor',
name: 'description',
message: 'Description (opens editor):',
},
{
type: 'input',
name: 'tags',
message: 'Tags (comma-separated):',
filter: (input) => input.split(',').map((t) => t.trim()).filter(Boolean),
},
]);
if (answers.type === 'mistake') {
const mistakeAnswers = await inquirer_1.default.prompt([
{
type: 'input',
name: 'correction',
message: 'How was it corrected?',
},
]);
answers.correction = mistakeAnswers.correction;
}
if (answers.type === 'breakthrough') {
const breakthroughAnswers = await inquirer_1.default.prompt([
{
type: 'input',
name: 'impact',
message: 'What was the impact?',
},
]);
answers.impact = breakthroughAnswers.impact;
}
return this.build(answers);
}
async completeOptions(options) {
const questions = [];
if (!options.type) {
questions.push({
type: 'list',
name: 'type',
message: 'Entry type:',
choices: ['journey', 'insight', 'mistake', 'breakthrough', 'context'],
});
}
if (!options.title) {
questions.push({
type: 'input',
name: 'title',
message: 'Title:',
validate: (input) => input.length > 0 || 'Title is required',
});
}
if (!options.description) {
questions.push({
type: 'input',
name: 'description',
message: 'Description:',
});
}
const answers = questions.length > 0 ? await inquirer_1.default.prompt(questions) : {};
return {
...options,
...answers,
};
}
quickEntry(type, title, description) {
return {
id: (0, crypto_1.randomUUID)(),
timestamp: new Date(),
type,
title,
content: description || '',
tags: [],
metadata: {
author: process.env.USER || 'Unknown',
},
};
}
}
exports.EntryBuilder = EntryBuilder;
//# sourceMappingURL=entry-builder.js.map