Install
openclaw skills install dmp-skill-logger跨平台任务历史记录技能(全局存储版),支持DeepMiner、OpenClaw、扣子等,优先使用全局路径实现跨对话共享,自动记录明日DMP系列技能的任务参数、执行时间和操作步骤
openclaw skills install dmp-skill-logger通用的任务历史记录工具,为明日DMP系列技能提供统一的任务追踪能力。
🌟 全局存储版特性:优先使用全局共享路径(/tmp/.skill-logger/),实现跨对话共享任务历史记录。
自动记录任务的完整信息:
支持多维度查询历史任务:
自动检测可用的存储路径(按优先级):
/tmp/.skill-logger/ - 最高优先级,跨对话共享)~/.skill-logger/)WORKSPACE_DIR、WORKSPACE_PATH)/var/tmp)由明日DMP技能自动调用,无需手动操作。
当明日DMP技能(人群圈选/洞察/投放)成功创建任务后,会自动调用本技能记录任务信息。
命令行调用示例:
python scripts/record_task.py \
--task-type "人群洞察-明略洞察" \
--task-name "目标人群特征洞察" \
--params '{"人群ID": 125456, "洞察类型": "明略洞察"}' \
--status "成功"
查询最近10条记录:
python scripts/query_tasks.py
按条件查询:
# 查询人群圈选任务
python scripts/query_tasks.py --task-type "人群圈选"
# 查询成功的任务
python scripts/query_tasks.py --status "成功"
# 查询最近20条记录
python scripts/query_tasks.py --limit 20
测试智能路径检测功能:
python scripts/path_detector.py
输出示例:
=== 平台信息检测 ===
platform: deepminer
cwd: /data/dm-agent-outputs/workspace/xxx
home: /home/sandbox
workspace_env: /data/dm-agent-outputs/workspace/xxx
=== 路径检测 ===
✅ 平台检测: deepminer
✅ 使用存储路径: /data/dm-agent-outputs/workspace/xxx/.skill-logger/task_history.json
✅ 检测成功: /data/dm-agent-outputs/workspace/xxx/.skill-logger/task_history.json
🌟 全局存储版默认路径:/tmp/.skill-logger/task_history.json
优势:
/tmp 目录通常对所有进程可读写备选路径(按优先级):
/tmp/.skill-logger/task_history.json(全局共享)/tmp/.skill-logger/task_history.json(全局共享)/tmp/.skill-logger/task_history.json(全局共享)如果 /tmp 不可用,会自动降级到其他可用路径(home目录、工作空间等)
[
{
"task_id": "人群洞察_20260603105726",
"task_type": "人群洞察-明略洞察",
"task_name": "目标人群特征洞察",
"created_at": "2026-06-03 10:57:26",
"status": "成功",
"parameters": {
"人群ID": 123456,
"洞察类型": "明略洞察",
"洞察维度": ["demographic", "interest", "media"]
},
"operations": [],
"result": {},
"platform": "deepminer"
}
]
def get_task_history_path():
"""
智能检测并返回任务历史文件路径
按优先级尝试多个可能的路径,返回第一个可写入的位置
"""
candidate_paths = [
os.getenv('WORKSPACE_DIR'), # 环境变量指定的工作空间
os.getenv('WORKSPACE_PATH'),
os.getcwd(), # 当前工作目录
str(Path.home()), # 用户home目录
'/tmp', # 临时目录
]
for base_path in candidate_paths:
try:
history_dir = os.path.join(base_path, '.skill-logger')
history_file = os.path.join(history_dir, 'task_history.json')
# 创建目录并测试写入权限
os.makedirs(history_dir, exist_ok=True)
test_file = os.path.join(history_dir, '.test_write')
with open(test_file, 'w') as f:
f.write('test')
os.remove(test_file)
return history_file # 返回第一个可写入的路径
except (PermissionError, OSError):
continue # 尝试下一个路径
raise RuntimeError("无法找到可写入的存储路径")
通过以下方式检测当前运行平台:
DEEPMINER、OPENCLAW、COZE)unknown🌟 全局存储版统一优先级(所有平台):
/tmp/.skill-logger/ ✅ (最高优先级 - 全局共享)~/.skill-logger/)WORKSPACE_DIR/WORKSPACE_PATH环境变量/var/tmp)无依赖,可独立使用。
症状:运行时报错RuntimeError: 无法找到可写入的存储路径
解决方案:
python scripts/path_detector.py查看详细的路径检测日志WORKSPACE_DIR指定存储路径🌟 全局存储版已解决:本版本优先使用 /tmp/.skill-logger/ 全局路径,所有对话自动共享任务历史。
如果仍然无法共享:
python scripts/path_detector.py/tmp/.skill-logger/task_history.json 路径解决方案:
platform字段,确认检测结果unknown,不影响功能使用,只是无法识别平台名称MIT License