feat(ffs): add pressure monitoring and auto-compact tracking
Enhanced framework-stats.js to display real session data and prepare for auto-compact impact analysis. New Data Displayed: - Real session statistics (ID, message count, action count, timestamps) - Actual context pressure monitoring (level, score, last check time) - Auto-compact events section (ready to log compaction impact) - Component statistics (CrossReferenceValidator, BashCommandValidator) Pressure Monitoring: - Now shows NORMAL (not UNKNOWN) - Displays last check timestamp and message number - Tracks token count at pressure check Auto-Compact Infrastructure: - Structure ready to log compaction events - Will track: before/after tokens, reduction %, message #, pressure change - Currently shows 0 compactions (session hasn't compacted yet) Component Performance: - CrossReferenceValidator: 1,462 validations - BashCommandValidator: 978 validations, 109 blocks Files: scripts/framework-stats.js (enhanced getSessionStats, report building, display sections) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
04d62ff92a
commit
f66115a7e9
1 changed files with 99 additions and 8 deletions
|
|
@ -32,7 +32,23 @@ const PluralisticDeliberationOrchestrator = require('../src/services/Pluralistic
|
||||||
async function getSessionStats() {
|
async function getSessionStats() {
|
||||||
const sessionStatePath = path.join(__dirname, '../.claude/session-state.json');
|
const sessionStatePath = path.join(__dirname, '../.claude/session-state.json');
|
||||||
if (fs.existsSync(sessionStatePath)) {
|
if (fs.existsSync(sessionStatePath)) {
|
||||||
return JSON.parse(fs.readFileSync(sessionStatePath, 'utf8'));
|
const sessionState = JSON.parse(fs.readFileSync(sessionStatePath, 'utf8'));
|
||||||
|
|
||||||
|
// Extract pressure monitoring data
|
||||||
|
const pressureData = sessionState.last_framework_activity?.ContextPressureMonitor;
|
||||||
|
|
||||||
|
// Extract auto-compact events
|
||||||
|
const autoCompacts = sessionState.auto_compact_events || [];
|
||||||
|
|
||||||
|
// Extract component statistics
|
||||||
|
const componentStats = sessionState.framework_components || {};
|
||||||
|
|
||||||
|
return {
|
||||||
|
...sessionState,
|
||||||
|
pressureMonitoring: pressureData,
|
||||||
|
autoCompactEvents: autoCompacts,
|
||||||
|
componentStatistics: componentStats
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -156,10 +172,13 @@ async function main() {
|
||||||
const report = {
|
const report = {
|
||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
session: sessionStats ? {
|
session: sessionStats ? {
|
||||||
sessionId: sessionStats.sessionId,
|
sessionId: sessionStats.session_id,
|
||||||
startTime: sessionStats.startTime,
|
startTime: sessionStats.started,
|
||||||
messageCount: sessionStats.messageCount,
|
messageCount: sessionStats.message_count,
|
||||||
status: sessionStats.status
|
tokenEstimate: sessionStats.token_estimate,
|
||||||
|
actionCount: sessionStats.action_count,
|
||||||
|
lastUpdated: sessionStats.last_updated,
|
||||||
|
initialized: sessionStats.initialized
|
||||||
} : null,
|
} : null,
|
||||||
|
|
||||||
tokenUsage: tokenCheckpoints ? {
|
tokenUsage: tokenCheckpoints ? {
|
||||||
|
|
@ -168,7 +187,13 @@ async function main() {
|
||||||
nextCheckpoint: tokenCheckpoints.checkpoints.find(c => !c.reached)
|
nextCheckpoint: tokenCheckpoints.checkpoints.find(c => !c.reached)
|
||||||
} : null,
|
} : null,
|
||||||
|
|
||||||
contextPressure: latestPressure ? {
|
contextPressure: sessionStats?.pressureMonitoring ? {
|
||||||
|
level: sessionStats.pressureMonitoring.last_level || 'UNKNOWN',
|
||||||
|
score: sessionStats.pressureMonitoring.last_score || 0,
|
||||||
|
lastChecked: sessionStats.pressureMonitoring.timestamp,
|
||||||
|
messageNumber: sessionStats.pressureMonitoring.message,
|
||||||
|
tokenCount: sessionStats.pressureMonitoring.tokens
|
||||||
|
} : (latestPressure ? {
|
||||||
level: latestPressure.pressureLevel?.name || 'UNKNOWN',
|
level: latestPressure.pressureLevel?.name || 'UNKNOWN',
|
||||||
score: latestPressure.overallScore,
|
score: latestPressure.overallScore,
|
||||||
timestamp: latestPressure.timestamp,
|
timestamp: latestPressure.timestamp,
|
||||||
|
|
@ -177,7 +202,28 @@ async function main() {
|
||||||
level: 'UNKNOWN',
|
level: 'UNKNOWN',
|
||||||
score: 0,
|
score: 0,
|
||||||
stats: monitorStats
|
stats: monitorStats
|
||||||
} : null),
|
} : null)),
|
||||||
|
|
||||||
|
autoCompacts: sessionStats?.autoCompactEvents ? {
|
||||||
|
total: sessionStats.autoCompactEvents.length,
|
||||||
|
events: sessionStats.autoCompactEvents.map(e => ({
|
||||||
|
timestamp: e.timestamp,
|
||||||
|
beforeTokens: e.before_tokens,
|
||||||
|
afterTokens: e.after_tokens,
|
||||||
|
reduction: e.reduction_percent,
|
||||||
|
messageNumber: e.message_number,
|
||||||
|
pressureBefore: e.pressure_before,
|
||||||
|
pressureAfter: e.pressure_after
|
||||||
|
}))
|
||||||
|
} : { total: 0, events: [] },
|
||||||
|
|
||||||
|
componentStats: sessionStats?.componentStatistics ? Object.entries(sessionStats.componentStatistics).map(([name, stats]) => ({
|
||||||
|
name,
|
||||||
|
validations: stats.validations_performed,
|
||||||
|
blocks: stats.blocks_issued,
|
||||||
|
lastActivity: stats.last_validation,
|
||||||
|
tokenCount: stats.tokens
|
||||||
|
})) : [],
|
||||||
|
|
||||||
instructions: instructionStats,
|
instructions: instructionStats,
|
||||||
|
|
||||||
|
|
@ -209,7 +255,10 @@ async function main() {
|
||||||
console.log(` Session ID: ${report.session.sessionId}`);
|
console.log(` Session ID: ${report.session.sessionId}`);
|
||||||
console.log(` Start Time: ${new Date(report.session.startTime).toLocaleString()}`);
|
console.log(` Start Time: ${new Date(report.session.startTime).toLocaleString()}`);
|
||||||
console.log(` Message Count: ${report.session.messageCount}`);
|
console.log(` Message Count: ${report.session.messageCount}`);
|
||||||
console.log(` Status: ${report.session.status}`);
|
console.log(` Token Estimate: ${report.session.tokenEstimate?.toLocaleString() || 'N/A'}`);
|
||||||
|
console.log(` Action Count: ${report.session.actionCount || 0}`);
|
||||||
|
console.log(` Last Updated: ${new Date(report.session.lastUpdated).toLocaleString()}`);
|
||||||
|
console.log(` Initialized: ${report.session.initialized ? 'Yes' : 'No'}`);
|
||||||
console.log();
|
console.log();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -231,6 +280,11 @@ async function main() {
|
||||||
console.log('⚠️ CONTEXT PRESSURE');
|
console.log('⚠️ CONTEXT PRESSURE');
|
||||||
console.log(` Level: ${report.contextPressure.level}`);
|
console.log(` Level: ${report.contextPressure.level}`);
|
||||||
console.log(` Overall Score: ${report.contextPressure.score}%`);
|
console.log(` Overall Score: ${report.contextPressure.score}%`);
|
||||||
|
if (report.contextPressure.lastChecked) {
|
||||||
|
console.log(` Last Checked: ${new Date(report.contextPressure.lastChecked).toLocaleString()}`);
|
||||||
|
console.log(` At Message: #${report.contextPressure.messageNumber}`);
|
||||||
|
console.log(` Token Count: ${report.contextPressure.tokenCount?.toLocaleString() || 'N/A'}`);
|
||||||
|
}
|
||||||
if (report.contextPressure.timestamp) {
|
if (report.contextPressure.timestamp) {
|
||||||
console.log(` Last Updated: ${new Date(report.contextPressure.timestamp).toLocaleString()}`);
|
console.log(` Last Updated: ${new Date(report.contextPressure.timestamp).toLocaleString()}`);
|
||||||
}
|
}
|
||||||
|
|
@ -248,6 +302,43 @@ async function main() {
|
||||||
console.log();
|
console.log();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Auto-Compact Events
|
||||||
|
if (report.autoCompacts) {
|
||||||
|
console.log('🔄 AUTO-COMPACT EVENTS');
|
||||||
|
console.log(` Total Compactions: ${report.autoCompacts.total}`);
|
||||||
|
if (report.autoCompacts.total > 0) {
|
||||||
|
console.log('\n Recent Compactions:');
|
||||||
|
report.autoCompacts.events.slice(-5).forEach((event, idx) => {
|
||||||
|
console.log(`\n ${idx + 1}. ${new Date(event.timestamp).toLocaleString()}`);
|
||||||
|
console.log(` Message #${event.messageNumber}`);
|
||||||
|
console.log(` Tokens: ${event.beforeTokens?.toLocaleString()} → ${event.afterTokens?.toLocaleString()} (${event.reduction}% reduction)`);
|
||||||
|
if (event.pressureBefore) {
|
||||||
|
console.log(` Pressure: ${event.pressureBefore} → ${event.pressureAfter}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log(' No auto-compaction events recorded yet.');
|
||||||
|
console.log(' (Framework will log compactions as they occur)');
|
||||||
|
}
|
||||||
|
console.log();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Component Statistics
|
||||||
|
if (report.componentStats && report.componentStats.length > 0) {
|
||||||
|
console.log('🔧 COMPONENT STATISTICS');
|
||||||
|
report.componentStats.forEach(comp => {
|
||||||
|
console.log(`\n ${comp.name}:`);
|
||||||
|
console.log(` Validations: ${comp.validations?.toLocaleString() || 'N/A'}`);
|
||||||
|
if (comp.blocks !== undefined) {
|
||||||
|
console.log(` Blocks Issued: ${comp.blocks}`);
|
||||||
|
}
|
||||||
|
if (comp.lastActivity) {
|
||||||
|
console.log(` Last Active: ${new Date(comp.lastActivity).toLocaleString()}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log();
|
||||||
|
}
|
||||||
|
|
||||||
// Instruction Stats
|
// Instruction Stats
|
||||||
if (report.instructions) {
|
if (report.instructions) {
|
||||||
console.log('📋 INSTRUCTIONS');
|
console.log('📋 INSTRUCTIONS');
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue