ai-dev-diary
Version:
Intelligent development diary system for AI-assisted projects
111 lines (109 loc) • 4.38 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.aiDiary = exports.AIAgentProtocol = void 0;
exports.startAISession = startAISession;
exports.readContext = readContext;
exports.logInsight = logInsight;
exports.logMistake = logMistake;
exports.endAISession = endAISession;
const diary_manager_1 = require("../core/diary-manager");
const entry_builder_1 = require("../core/entry-builder");
class AIAgentProtocol {
diaryManager;
entryBuilder;
sessionStartTime;
sessionInsights = [];
sessionMistakes = [];
constructor(basePath = '.ai-diary') {
this.diaryManager = new diary_manager_1.DiaryManager(basePath);
this.entryBuilder = new entry_builder_1.EntryBuilder();
this.sessionStartTime = new Date();
}
async startSession() {
this.sessionStartTime = new Date();
this.sessionInsights = [];
this.sessionMistakes = [];
await this.readContext();
console.log('AI Session started. Current context loaded.');
}
async readContext() {
return await this.diaryManager.getContext();
}
async logInsight(insight) {
this.sessionInsights.push(insight);
const entry = this.entryBuilder.quickEntry('insight', insight.slice(0, 50) + (insight.length > 50 ? '...' : ''), insight);
entry.metadata.aiAgent = process.env.AI_MODEL || 'ai-agent';
await this.diaryManager.saveEntry(entry);
}
async logMistake(mistake, correction) {
this.sessionMistakes.push({ mistake, correction });
const entry = this.entryBuilder.quickEntry('mistake', mistake.slice(0, 50) + (mistake.length > 50 ? '...' : ''), mistake);
entry.metadata.aiAgent = process.env.AI_MODEL || 'ai-agent';
entry.metadata.correction = correction;
await this.diaryManager.saveEntry(entry);
}
async logJourney(title, description) {
const entry = this.entryBuilder.quickEntry('journey', title, description);
entry.metadata.aiAgent = process.env.AI_MODEL || 'ai-agent';
await this.diaryManager.saveEntry(entry);
}
async logBreakthrough(title, description, impact) {
const entry = this.entryBuilder.quickEntry('breakthrough', title, description);
entry.metadata.aiAgent = process.env.AI_MODEL || 'ai-agent';
entry.metadata.impact = impact;
await this.diaryManager.saveEntry(entry);
}
async updateContext(updates) {
await this.diaryManager.updateContext(updates);
}
async endSession(summary) {
const sessionDuration = new Date().getTime() - this.sessionStartTime.getTime();
const durationMinutes = Math.round(sessionDuration / 1000 / 60);
const sessionSummary = `
Session Summary:
- Duration: ${durationMinutes} minutes
- Insights logged: ${this.sessionInsights.length}
- Mistakes logged: ${this.sessionMistakes.length}
- Summary: ${summary}
Key Insights:
${this.sessionInsights.map(i => `• ${i}`).join('\n') || '(none)'}
Mistakes Corrected:
${this.sessionMistakes.map(m => `• ${m.mistake} → ${m.correction}`).join('\n') || '(none)'}
`.trim();
const entry = this.entryBuilder.quickEntry('journey', `AI Session Summary - ${new Date().toISOString().split('T')[0]}`, sessionSummary);
entry.metadata.aiAgent = process.env.AI_MODEL || 'ai-agent';
await this.diaryManager.saveEntry(entry);
const context = await this.readContext();
await this.updateContext({
recentChanges: [...context.recentChanges, summary].slice(-10),
});
}
async searchRelevantEntries(query) {
console.log(`Searching for: ${query}`);
return [];
}
async getPatterns() {
return [];
}
async checkPreviousMistakes(_description) {
return false;
}
}
exports.AIAgentProtocol = AIAgentProtocol;
exports.aiDiary = new AIAgentProtocol();
async function startAISession() {
return exports.aiDiary.startSession();
}
async function readContext() {
return exports.aiDiary.readContext();
}
async function logInsight(insight) {
return exports.aiDiary.logInsight(insight);
}
async function logMistake(mistake, correction) {
return exports.aiDiary.logMistake(mistake, correction);
}
async function endAISession(summary) {
return exports.aiDiary.endSession(summary);
}
//# sourceMappingURL=ai-agents.js.map