← Back to Skills Marketplace
534422530

会话日志分析

by 534422530 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
50
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install laosi-session-logs
Description
会话日志分析 - 搜索和分析历史会话日志,查找之前的对话内容和结果。
README (SKILL.md)

Session Logs - 会话日志分析

激活词: 会话日志 / 搜索历史 / 历史记录

功能

  • 搜索历史会话
  • 分析会话模式
  • 提取关键信息
  • 按时间过滤

Python实现

import json
import os
from datetime import datetime, timedelta
from pathlib import Path

class SessionLogs:
    def __init__(self, log_dir: str = "~/.openclaw/logs"):
        self.log_dir = Path(log_dir).expanduser()
    
    def list_sessions(self, days: int = 7) -> list:
        sessions = []
        cutoff = datetime.now() - timedelta(days=days)
        
        for file in self.log_dir.glob("*.log"):
            mtime = datetime.fromtimestamp(file.stat().st_mtime)
            if mtime > cutoff:
                sessions.append({
                    'file': file.name,
                    'modified': mtime,
                    'size': file.stat().st_size
                })
        
        return sorted(sessions, key=lambda x: x['modified'], reverse=True)
    
    def search_logs(self, keyword: str, days: int = 7) -> list:
        results = []
        for file in self.log_dir.glob("*.log"):
            try:
                with open(file, 'r', encoding='utf-8', errors='ignore') as f:
                    for i, line in enumerate(f, 1):
                        if keyword.lower() in line.lower():
                            results.append({
                                'file': file.name,
                                'line': i,
                                'content': line.strip()[:200]
                            })
            except:
                pass
        return results
    
    def extract_commands(self, log_file: str) -> list:
        commands = []
        with open(self.log_dir / log_file, 'r') as f:
            for line in f:
                if 'command:' in line.lower() or 'user:' in line.lower():
                    commands.append(line.strip())
        return commands

使用示例

logs = SessionLogs()

# 列出最近7天会话
recent = logs.list_sessions(7)
for s in recent:
    print(f"{s['modified']}: {s['file']}")

# 搜索关键词
results = logs.search_logs("Python", days=30)
for r in results:
    print(f"{r['file']}:{r['line']}: {r['content']}")

输出格式

## 会话日志

### 最近会话
| 日期 | 文件 | 大小 |
|------|------|------|
| 2026-04-28 | 2026-04-28.log | 1.2MB |
| 2026-04-27 | 2026-04-27.log | 2.3MB |

### 搜索结果 "Python"
- 2026-04-28.log:142: "用Python写个脚本..."
- 2026-04-27.log:89: "Python怎么导入模块"
Usage Guidance
This is an instruction-only skill that reads log files from ~/.openclaw/logs to list and search past sessions. It does not ask for credentials or download code. Before installing, confirm that: (1) you are comfortable with a tool reading files in ~/.openclaw/logs (these logs may contain sensitive data or commands), (2) the log directory location is correct for your environment, and (3) you want the agent to be able to access that data when the skill runs. Note the example code has minor bugs (search ignores the days parameter and returns raw line snippets that could include secrets); consider reviewing or testing the code locally, adding mtime filtering, limiting result size, and sanitizing outputs before using in production.
Capability Analysis
Type: OpenClaw Skill Name: laosi-session-logs Version: 1.0.0 The skill provides legitimate functionality for searching and analyzing local OpenClaw session logs stored in ~/.openclaw/logs. The Python implementation in SKILL.md uses standard libraries for file I/O and lacks any indicators of data exfiltration, remote execution, or malicious intent.
Capability Assessment
Purpose & Capability
Name/description (session log search and analysis) match the instructions and example code, which operate on a local log directory (~/.openclaw/logs). No unrelated credentials, binaries, or installs are requested.
Instruction Scope
SKILL.md contains Python code that reads and searches log files in ~/.openclaw/logs — this matches purpose. Minor implementation issues: search_logs accepts a days parameter but does not filter by modification time (it will scan all *.log files), exceptions are broadly swallowed, and extract_commands reads file contents without encoding/options. These are correctness/privacy concerns but not evidence of hidden behavior.
Install Mechanism
No install spec and no code files beyond SKILL.md (instruction-only). Nothing is written to disk or downloaded by the skill itself.
Credentials
No environment variables, credentials, or external config paths are required. The only resource accessed is a local path (~/.openclaw/logs), which is consistent with a session-log analysis tool.
Persistence & Privilege
always is false and the skill does not request persistent/system-wide configuration or elevated privileges. Autonomous invocation is allowed by default but is not combined with other red flags.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install laosi-session-logs
  3. After installation, invoke the skill by name or use /laosi-session-logs
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
搜索和分析历史会话
Metadata
Slug laosi-session-logs
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is 会话日志分析?

会话日志分析 - 搜索和分析历史会话日志,查找之前的对话内容和结果。 It is an AI Agent Skill for Claude Code / OpenClaw, with 50 downloads so far.

How do I install 会话日志分析?

Run "/install laosi-session-logs" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is 会话日志分析 free?

Yes, 会话日志分析 is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does 会话日志分析 support?

会话日志分析 is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created 会话日志分析?

It is built and maintained by 534422530 (@534422530); the current version is v1.0.0.

💬 Comments