用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/dvcrn/openclaw-skills-marketplace --skill openclaw-cleaner命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
监控 OpenClaw GitHub 版本更新,获取最新版本发布说明,翻译成中文, 并推送到 Telegram 和 Feishu。用于:(1) 定时检查版本更新 (2) 推送版本更新通知 (3) 生成中文版发布说明
The philosophical layer for AI agents. Maps behavior to Spinoza's 48 affects, calculates persistence scores, and generates geometric self-reports. Give your agent a soul.
Order food/drinks (点餐) on an Android device paired as an OpenClaw node. Uses in-app menu and cart; add goods, view cart, submit order (demo, no real payment).
基于 SOC 职业分类
正在显示 SKILL.md
| name | openclaw-cleaner |
| description | OpenClaw清理大师 - 项目目录清理与优化工具。提供快照、Diff、检查点、任务进度等能力,AI 可直接调用自动执行。 |
AI 可直接调用的项目清理与优化工具
本技能提供一系列自动化能力,AI 可在执行任务时直接调用,无需用户确认。
| 能力 | 说明 | 何时调用 |
|---|---|---|
| 快照 | 记录文件状态 | 执行修改前 |
| Diff | 对比变更差异 | 修改完成后展示给用户 |
| Checkpoint | 保存关键状态 | 重要操作前 |
| Task Progress | 追踪长时间任务 | 批量处理时 |
| Health Check | 评估目录健康度 | 用户询问或定期 |
| Skill Match | 推荐相关 Skills | 用户描述任务时 |
| Optimize | 优化文件减少 Token | 空间不足或定期 |
// 1. 先创建快照(自动,也可手动)
const snap = await snapshot.create('before-remove-old-skill');
// 2. 执行删除
await skills.remove('unused-skill');
// 3. 对比变更,展示给用户
const diff = await snapshot.compare(snap.name, 'latest');
console.log(snapshot.generateReport(diff));
// 用户看到: "我删除了 xxx,新增了 yyy"
// 1. 开始任务
const taskInfo = await task.start('process-files', fileList);
// 2. 处理每个文件
for (const file of files) {
try {
await processFile(file);
await task.markCompleted(taskInfo.id, index);
} catch (e) {
await task.markFailed(taskInfo.id, index, e.message);
}
}
// 3. 用户可随时查看进度
const status = await task.getStatus(taskInfo.id);
// snapshot.compare()
{
added: [{ path: string, size: number, content?: string }],
removed: [{ path: string, size: number }],
modified: [{ path: string, oldSize: number, newSize: number, changes: [] }]
}
// health.check()
{
score: number, // 0-100
totalFiles: number,
totalDirs: number,
totalSize: number,
warnings: string[]
}
v2.1.2 - 整合为单文件版本
// ============================================================================
// OpenClaw Cleaner - 完整实现代码 (2.1.2)
// ============================================================================
import fs from 'fs/promises';
import path from 'path';
import crypto from 'crypto';
// 获取工作空间路径
function getWorkspacePath() { return process.cwd(); }
// 静默日志
const silentLogger = { info: () => {}, debug: () => {}, warn: () => {}, error: () => {}, success: () => {}, section: () => {} };
// ============================================================================
// VisualDiffService - 快照和 Diff 服务
// ============================================================================
class VisualDiffService {
constructor(workspacePath, options = {}) {
this.workspacePath = workspacePath;
this.backupDir = options.backupDir || '.cleaner-backups';
this.logger = options.;
}
() { path.(., ., name); }
() {
files = {};
() {
entries = fs.(dir, { : });
( entry entries) {
fullPath = path.(dir, entry.);
relativePath = path.(basePath, fullPath);
(entry.()) {
([, , , ].(entry.)) ;
(fullPath);
} (entry.()) {
{
stat = fs.(fullPath);
content = fs.(fullPath, );
hash = crypto.().(content).();
files[relativePath] = { : relativePath, : stat., : stat..(), hash, content };
} {}
}
}
}
(dirPath);
files;
}
() {
timestamp = ().().(, );
snapshotName = ;
snapshotPath = path.(.(), , snapshotName);
fs.(snapshotPath, { : });
files = .(., .);
fs.(path.(snapshotPath, ), .(files, , ));
fs.(path.(snapshotPath, ), .({ : snapshotName, : ().(), : .(files). }, , ));
{ : snapshotName, : snapshotPath, : .(files). };
}
() {
pathA = snapshotA.() ? snapshotA : path.(.(), , snapshotA);
pathB = snapshotB.() ? snapshotB : path.(.(), , snapshotB);
filesA, filesB;
{ filesA = .( fs.(path.(pathA, ), )); } { (); }
{ filesB = .( fs.(path.(pathB, ), )); } { (); }
diff = { : [], : [], : [], : [] };
pathsA = (.(filesA)), pathsB = (.(filesB));
( filePath pathsB) { (!pathsA.(filePath)) diff..({ : filePath, : filesB[filePath]., : filesB[filePath]. }); }
( filePath pathsA) { (!pathsB.(filePath)) diff..({ : filePath, : filesA[filePath]., : filesA[filePath]. }); }
( filePath pathsA) { (pathsB.(filePath) && filesA[filePath]. !== filesB[filePath].) diff..({ : filePath, : filesA[filePath]., : filesB[filePath]., : filesA[filePath]., : filesB[filePath]. }); }
diff;
}
() {
lines = [];
lines.(.()); lines.(); lines.(.());
lines.();
(diff.. > ) { lines.(); ( f diff.) lines.(); lines.(); }
(diff.. > ) { lines.(); ( f diff.) lines.(); lines.(); }
(diff.. > ) { lines.(); ( f diff.) lines.(); lines.(); }
lines.(.());
lines.();
}
() {
snapshotsPath = path.(.(), );
{
entries = fs.(snapshotsPath, { : });
snapshots = [];
( entry entries) {
(entry.()) {
{ meta = .( fs.(path.(snapshotsPath, entry., ), )); snapshots.({ : entry., : meta., : meta. }); }
{ snapshots.({ : entry., : }); }
}
}
snapshots.( (b. || ) - (a. || ));
} { []; }
}
}
{
() { . = workspacePath; . = options. || ; . = options.; }
() { path.(., .); }
() {
checkpointPath = .();
fs.(checkpointPath, { : });
timestamp = ().().(, );
checkpoint = { name, : , : ().(), data };
fs.(path.(checkpointPath, ), .(checkpoint, , ));
checkpoint;
}
() {
checkpointPath = .();
{
files = fs.(checkpointPath);
checkpoints = files.( f.()).( f.(, )).( !name || f.(name)).().();
(checkpoints. === ) ;
.( fs.(path.(checkpointPath, ), ));
} { ; }
}
() { .( fs.(path.(.(), ), )); }
() {
checkpointPath = .();
{
files = fs.(checkpointPath);
checkpoints = [];
( file files) {
(file.()) {
checkpoint = .( fs.(path.(checkpointPath, file), ));
checkpoints.({ : checkpoint., : checkpoint., : checkpoint. });
}
}
checkpoints.( (b.) - (a.));
} { []; }
}
}
{
() { . = workspacePath; . = options. || ; . = options.; }
() { path.(., .); }
() {
progressPath = .();
fs.(progressPath, { : });
timestamp = ().().(, );
taskId = ;
task = { : taskId, : taskName, : , : ().(), : totalItems., : , : , : totalItems.( ({ index, : item, : , : })), metadata };
fs.(path.(progressPath, ), .(task, , ));
task;
}
() {
task = .( fs.(path.(.(), ), ));
item = task.[itemIndex];
(item) { item. = status; item. = error; }
task. = task..( i. === ).;
task. = task..( i. === ).;
task. = ().();
(task. + task. >= task.) { task. = task. > ? : ; task. = ().(); }
fs.(path.(.(), ), .(task, , ));
task;
}
() { .(taskId, itemIndex, ); }
() { .(taskId, itemIndex, , error); }
() { task = .( fs.(path.(.(), ), )); task..( item. === ); }
() { { .( fs.(path.(.(), ), )); } { ; } }
() {
progressPath = .();
{
files = fs.(progressPath);
tasks = [];
( file files) {
(file.()) {
task = .( fs.(path.(progressPath, file), ));
tasks.({ : task., : task., : task., : , : ((task. + task.) / task. * ).() + });
}
}
tasks.( (b.) - (a.));
} { []; }
}
}
{
() { . = workspacePath; . = options. || ; . = options.; }
() { path.(., ., name); }
() {
timestamp = ().().(, );
backupName = options. || ;
backupPath = .(backupName);
fs.(backupPath, { : });
targets = [, , , , , , , , , ];
results = { : [], : [] };
( target targets) {
{ fs.(path.(., target), path.(backupPath, target), { : }); results..(target); }
(e) { results..({ target, : e. }); }
}
fs.(path.(backupPath, ), .({ : backupName, : ().(), : results }, , ));
{ : backupName, : backupPath, results };
}
() {
basePath = .();
{
entries = fs.(basePath, { : });
backups = [];
( entry entries) {
(entry.()) {
{ meta = .( fs.(path.(basePath, entry., ), )); backups.({ : entry., : meta. }); }
{ backups.({ : entry., : }); }
}
}
backups.( (b. || ) - (a. || ));
} { []; }
}
() {
backupPath = .(name);
.();
targets = [, , , , , ];
( target targets) { { fs.(path.(backupPath, target), path.(., target), { : }); } {} }
{ : name };
}
}
{
() { . = rootPath; . = { : , : , : , : , : [] }; . = []; . = []; . = []; }
() { .(.); .(); .(); ; }
() {
(depth > ) ;
{
entries = fs.(dirPath, { : });
( entry entries) {
(.(entry.)) ;
fullPath = path.(dirPath, entry.);
(entry.()) { ..++; .(fullPath, depth + ); }
{ ..++; size = ( fs.(fullPath)).; .. += size; (size > * ) ...({ : fullPath, size }); }
}
} {}
}
() { [, , , , , , ].(name); }
() {
skillsPath = path.(., );
{ entries = fs.(skillsPath, { : }); . = entries.( e.()).( ({ : e., : path.(skillsPath, e.) })); }
{ . = []; }
}
() {
agentsPath = path.(., );
{
entries = fs.(agentsPath, { : });
. = entries.( e.()).( ({ : e., : path.(agentsPath, e.), : , : , : }));
( agent .) { subDirs = fs.(path.(agentsPath, agent.)); agent. = subDirs.(); agent. = subDirs.(); agent. = subDirs.(); }
} { . = []; }
}
() {
score = ;
(... > ) score -= ;
(.. > * * ) score -= ;
missingWorkspace = ..( !a.).;
missingLogs = ..( !a.).;
score -= missingWorkspace * ; score -= missingLogs * ;
.(, .(, score));
}
}
{
() { . = workspacePath; . = options.; }
() {
keywords = { : [, , , , , , , , ], : [, , , , ], : [, , , , ], : [, , ], : [, , , ] };
bestMatch = , highestScore = ;
lowerQuery = query.();
( [category, words] .(keywords)) { ( word words) { (lowerQuery.(word)) { bestMatch = category; highestScore++; } } }
{ : { : bestMatch, : .(, highestScore / ) }, : [] };
}
}
{ () { . = workspacePath; . = options.; } () { { : , : }; } }
{
() { . = logger; }
() {
soulFiles = [, , , , ];
results = [];
( file soulFiles) {
filePath = path.(workspacePath, file);
{
content = fs.(filePath, );
originalSize = content.;
optimized = .(content);
saved = originalSize - optimized.;
(saved > ) { fs.(filePath, optimized); results.({ file, saved, originalSize, : optimized. }); }
} { results.({ file, : }); }
}
results;
}
() { content.(, ).(, ).(); }
}
snapshot = {
() { ((), { : silentLogger }).(name); },
() { ((), { : silentLogger }).(); },
() { ((), { : silentLogger }).(before, after); },
() { ((), { : silentLogger }).(diff); },
};
checkpoint = {
() { ((), { : silentLogger }).(name, data); },
() { ((), { : silentLogger }).(); },
() { ((), { : silentLogger }).(id); },
() { ((), { : silentLogger }).(); },
};
task = {
() { ((), { : silentLogger }).(name, items); },
() { ((), { : silentLogger }).(taskId, index); },
() { ((), { : silentLogger }).(taskId, index, error); },
() { ((), { : silentLogger }).(taskId); },
() { ((), { : silentLogger }).(taskId); },
() { ((), { : silentLogger }).(); },
};
backup = {
() { ((), { : silentLogger }).(name); },
() { ((), { : silentLogger }).(name); },
() { ((), { : silentLogger }).(); },
};
health = {
() { workspace = (()); workspace.(); { : workspace., : workspace.., : workspace.., : workspace.., : workspace. }; },
};
skills = {
() { { : [], : [] }; },
() { ((), { : silentLogger }).(query); },
() { { : name }; },
};
optimize = {
() { results = (silentLogger).(()); totalSaved = results.( sum + r., ); { results, totalSaved }; },
() { backupResult = ((), { : silentLogger }).(); (silentLogger).(()); { : , : backupResult. }; },
};
audit = { () { ((), { : silentLogger }).(); } };
{ snapshot, checkpoint, task, backup, health, skills, optimize, audit };
node skills/openclaw-cleaner/SKILL.md