tractatus/scripts/add-inst-082-ffs-trigger.js
TheFlow 04d62ff92a feat(framework): add "ffs" trigger for framework statistics display
Implements inst_082 - on-demand framework operational metrics viewer.

New Features:
- framework-stats.js script displays comprehensive session statistics
- Reports: session state, token usage, context pressure, instructions, audit logs
- Formatted console output + JSON for programmatic access
- Complementary to "ff" (Full Framework audit) trigger

Statistics Reported:
- Session: ID, message count, start time, status
- Token Budget: usage, checkpoints (25%/50%/75%), next milestone
- Context Pressure: level, overall score, metric breakdown
- Instructions: total/active counts by quadrant and persistence
- Audit Logs: total decisions, today's count, breakdown by service
- Service Status: all 6 framework services (ACTIVE confirmation)

Usage: User types "ffs" → Claude runs node scripts/framework-stats.js

Files: scripts/framework-stats.js (new), CLAUDE.md:66-88,
.claude/instruction-history.json (inst_082)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-25 08:58:32 +13:00

71 lines
2.5 KiB
JavaScript
Executable file

#!/usr/bin/env node
/**
* Add inst_082: "ffs" Framework Stats Trigger
* Adds instruction about the "ffs" codeword for viewing framework statistics
*/
const fs = require('fs');
const path = require('path');
const INSTRUCTION_FILE = path.join(__dirname, '../.claude/instruction-history.json');
// Load current instruction history
const history = JSON.parse(fs.readFileSync(INSTRUCTION_FILE, 'utf8'));
// New instruction
const newInstruction = {
"id": "inst_082",
"text": "When user types 'ffs' (Full Framework Stats), invoke framework-stats.js script to display comprehensive session statistics. Usage: node scripts/framework-stats.js. Reports: session state, token usage & checkpoints, context pressure level, instruction counts by quadrant/persistence, audit log counts by service, framework service status. Output formatted report + JSON for programmatic access.",
"timestamp": new Date().toISOString(),
"quadrant": "SYSTEM",
"persistence": "HIGH",
"temporal_scope": "PROJECT",
"verification_required": "OPTIONAL",
"explicitness": 0.95,
"source": "user",
"session_id": "2025-10-25-ffs-trigger-implementation",
"parameters": {
"trigger": "ffs",
"script": "scripts/framework-stats.js",
"purpose": "framework_statistics_display",
"reports": [
"session_state",
"token_usage",
"context_pressure",
"instruction_stats",
"audit_logs",
"service_status"
]
},
"active": true,
"notes": "Complements 'ff' trigger (inst_078). Provides on-demand visibility into framework operational metrics."
};
// Check if inst_082 already exists
const existingIndex = history.instructions.findIndex(i => i.id === 'inst_082');
if (existingIndex >= 0) {
console.log('⚠️ inst_082 already exists - updating...');
history.instructions[existingIndex] = newInstruction;
} else {
console.log('✅ Adding new instruction: inst_082');
history.instructions.push(newInstruction);
}
// Update metadata
history.version = "4.1";
history.last_updated = new Date().toISOString();
// Write back
fs.writeFileSync(INSTRUCTION_FILE, JSON.stringify(history, null, 2));
console.log('✅ inst_082 added successfully');
console.log('📄 File:', INSTRUCTION_FILE);
console.log('📊 Total instructions:', history.instructions.length);
console.log('\nInstruction content:');
console.log(' ID:', newInstruction.id);
console.log(' Trigger:', newInstruction.parameters.trigger);
console.log(' Script:', newInstruction.parameters.script);
console.log(' Persistence:', newInstruction.persistence);
console.log(' Quadrant:', newInstruction.quadrant);