diff options
Diffstat (limited to 'modules/core/module-aiassist.js')
| -rw-r--r-- | modules/core/module-aiassist.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/modules/core/module-aiassist.js b/modules/core/module-aiassist.js index 0ef6a2f..f9e1e98 100644 --- a/modules/core/module-aiassist.js +++ b/modules/core/module-aiassist.js @@ -366,6 +366,13 @@ RULES: }, { type: 'function', function: { + name: 'session_terminal', + description: "Read the last ~50 lines of terminal output from the auto-saved session. Use this when the user references something they did in the terminal that you don't remember. Shows commands, outputs, and timestamps.", + parameters: { type: 'object', properties: {}, required: [] } + } + }, { + type: 'function', + function: { name: 'session_stats', description: 'Aggregate statistics across all sessions: total tasks, most-used tools, common topics.', parameters: { type: 'object', properties: {}, required: [] } @@ -1015,6 +1022,22 @@ RULES: const sessions = dates.map(d => ({ date: d, ...rindex[d] })); return JSON.stringify({ sessions, count: sessions.length }); } + case 'session_terminal': { + const tfs = this.terminal.fs; + try { + const raw = tfs.readFile('_sessions/_auto.json'); + if (!raw) return JSON.stringify({ error: 'No auto-saved session found' }); + const data = JSON.parse(raw); + const lines = (data.terminalLines || []).slice(-50); + const text = lines.map(l => { + const ts = l.t ? '[' + l.t + '] ' : ''; + return ts + l.l; + }).join('\n'); + return JSON.stringify({ lines: lines.length, output: text, savedAt: data.savedAt || '' }); + } catch (e) { + return JSON.stringify({ error: 'Could not read terminal history: ' + e.message }); + } + } case 'session_stats': { const sfs = this.terminal.fs; const sindex = sfs.fsReadJSON('/memory/index.json') || {}; |