📦 会话日志分析

v1.0.0

会话日志分析 - 搜索和分析历史会话日志,查找之前的对话内容和结果。

0· 0·0 当前·0 累计
0
安全扫描
VirusTotal
无害
查看报告
OpenClaw
安全
high confidence
The 技能 is an instruction-only 会话-记录 搜索/分析器 that only reads files under ~/.OpenClaw/记录s and does not 请求 凭证s or 安装 software; its 请求ed 访问 is coherent with its 状态d purpose.
评估建议
This is an instruction-only 技能 that reads 记录 files from ~/.OpenClaw/记录s to 列出 and 搜索 past 会话s. It does not ask for 凭证s or 下载 code. Before 安装ing, confirm that: (1) you are comfortable with a 工具 reading files in ~/.OpenClaw/记录s (these 记录s may contAIn sensitive data or commands), (2) the 记录 directory location is correct for your 环境, and (3) you want the 代理 to be able to 访问 that data when the 技能 运行s. Note the example code has minor bugs (搜索 ignores the days parameter and returns raw line snippets th...
详细分析 ▾
用途与能力
Name/description (会话 记录 搜索 and analysis) match the instructions and example code, which operate on a local 记录 directory (~/.OpenClaw/记录s). No unrelated 凭证s, binaries, or 安装s are 请求ed.
指令范围
SKILL.md 包含读取并搜索 ~/.openclaw/logs 日志文件的 Python 代码,符合其用途。实现上的小问题:search_logs 接受 days 参数但未按修改时间过滤(会扫描全部 *.log 文件),异常被笼统捕获,extract_commands 读取文件内容时未指定编码/选项。这些是正确性/隐私方面的顾虑,而非隐藏行为的证据。
安装机制
No 安装 spec and no code files beyond 技能.md (instruction-only). Nothing is written to disk or 下载ed by the 技能 itself.
凭证需求
No 环境 variables, 凭证s, or external config paths are required. The only resource 访问ed is a local path (~/.OpenClaw/记录s), which is consistent with a 会话-记录 analysis 工具.
持久化与权限
always is false and the 技能 does not 请求 persistent/系统-wide configuration or elevated privileges. Autonomous invocation is allowed by default but is not combined with other red flags.
安全有层次,运行前请审查代码。

运行时依赖

无特殊依赖

安装命令

点击复制
官方npx clawhub@latest install laosi-session-logs
镜像加速npx clawhub@latest install laosi-session-logs --registry https://cn.longxiaskill.com

技能文档

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

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

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怎么导入模块"
数据来源ClawHub ↗ · 中文优化:龙虾技能库