aboutsummaryrefslogtreecommitdiff
path: root/modules/core/module-system.js
diff options
context:
space:
mode:
Diffstat (limited to 'modules/core/module-system.js')
-rw-r--r--modules/core/module-system.js26
1 files changed, 19 insertions, 7 deletions
diff --git a/modules/core/module-system.js b/modules/core/module-system.js
index e7f7e5a..b9b62a6 100644
--- a/modules/core/module-system.js
+++ b/modules/core/module-system.js
@@ -144,13 +144,25 @@
// v4.5.43: errors [n] — alias for logs [n] ERROR
this.commands['errors'] = (args) => {
const n = parseInt(args[0]) || 20;
- const content = this.terminal.fs.readFile('/logs/current.log');
- if (!content) { this.terminal.print('No logs yet', 'info'); return; }
- const lines = content.split('\n').filter(l => l && l.includes('[ERROR]'));
- const tail = lines.slice(-n);
- if (tail.length === 0) { this.terminal.print('✅ No errors found in logs', 'success'); return; }
- this.terminal.print(`--- Errors (last ${tail.length}) ---`, 'error');
- tail.forEach(l => this.terminal.print(l, 'error'));
+ // v4.6.59: read the canonical counter (DebugSupervisor DB + failed tool
+ // calls) — the same numbers the dashboard and world model publish. The VFS
+ // log is reported separately because it only receives explicit
+ // terminal.log('ERROR') calls, so it cannot be the source of truth.
+ const e = this.terminal.countErrors();
+ if (e.total === 0) {
+ this.terminal.print(`✅ 0 errors — debug DB ${e.debug} · failed tool calls ${e.latency} · log ${e.log}`, 'success');
+ } else {
+ this.terminal.print(`--- ${e.total} ${e.total === 1 ? 'error' : 'errors'} — debug DB ${e.debug} · failed tool calls ${e.latency} ---`, 'error');
+ const ds = this.terminal.moduleManager.modules['DebugSupervisorModule'];
+ const entries = Object.entries((ds && ds._errorDB && ds._errorDB.errors) || {})
+ .map(([hash, v]) => Object.assign({ hash: hash }, v))
+ .sort((a, b) => (b.lastSeen || 0) - (a.lastSeen || 0))
+ .slice(0, n);
+ entries.forEach(x => this.terminal.print(
+ (x.hash || '').slice(0, 8) + ' ×' + (x.count || 1) + ' ' +
+ ((x.severity || '') + ' ' + (x.message || '')).trim(), 'error'));
+ }
+ this.terminal.print(` scope: this browser session · log scan ${e.log} [ERROR] line(s) in /logs/current.log`, 'info');
};
// v4.5.43: doctor — run all health checks, rank issues, show top 3