hassan-mohiddin/freeflow / .deprecated/skill-tooling-pre-rewrite/skills/evaluate-skill
evaluate-skill
VerifiedUse when evaluating, comparing, or making readiness claims about agent-skill behavior.
scripts/lib/hash.mjs
View on GitHubimport { createHash } from "node:crypto";
import { lstat, readFile, readdir, readlink } from "node:fs/promises";
import { relative, resolve } from "node:path";
import { spawnSync } from "node:child_process";
export function sha256(value) {
return createHash("sha256").update(value).digest("hex");
}
export function stableJson(value) {
if (Array.isArray(value)) return `[${value.map(stableJson).join(",")}]`;
if (value && typeof value === "object") {
return `{${Object.keys(value)
.sort()
.map((key) => `${JSON.stringify(key)}:${stableJson(value[key])}`)
.join(",")}}`;
}
return JSON.stringify(value);
}
export async function hashFile(path) {
return sha256(await readFile(path));
}
async function filesystemEntries(root, paths) {
const absoluteRoot = resolve(root);
const entries = [];
async function visit(path) {
const info = await lstat(path);
const rel = relative(absoluteRoot, path) || ".";
if (info.isSymbolicLink()) {
entries.push([rel, "symlink", await readlink(path)]);
return;
}
if (info.isDirectory()) {
const names = (await readdir(path)).sort();
for (const name of names) await visit(resolve(path, name));
return;
}
if (info.isFile()) entries.push([rel, "file", sha256(await readFile(path))]);
}
for (const path of paths) await visit(resolve(absoluteRoot, path));
return entries.sort((left, right) => left[0].localeCompare(right[0]));
}
export async function hashDirectory(root) {
return sha256(stableJson(await filesystemEntries(root, ["."])));
}
function resourceIdentity(entries) {
const ordered = [...entries].sort((left, right) => left[0].localeCompare(right[0]));
return { entries: ordered, aggregate_sha256: sha256(stableJson(ordered)) };
}
export async function declaredResourceIdentity(root, resources) {
return resourceIdentity(await filesystemEntries(root, [...resources].sort()));
}
export async function hashDeclaredResources(root, resources) {
return (await declaredResourceIdentity(root, resources)).aggregate_sha256;
}
export function gitResourceIdentity(repoRoot, revision, rootPath, resources) {
const root = rootPath.replace(/\/$/, "") === "." ? "" : rootPath.replace(/\/$/, "");
const entries = [];
for (const resource of [...resources].sort()) {
const fullResource = root ? `${root}/${resource}` : resource;
const result = spawnSync("git", ["ls-tree", "-r", "-z", "--full-tree", revision, "--", fullResource], {
cwd: repoRoot,
encoding: "utf8",
});
if (result.status !== 0)
throw new Error(`Unable to resolve git resource ${revision}:${fullResource}: ${result.stderr.trim()}`);
const records = result.stdout.split("\0").filter(Boolean);
if (records.length === 0) throw new Error(`Git subject resource is empty: ${revision}:${fullResource}`);
for (const record of records) {
const [header, fullPath] = record.split("\t");
const [mode, type] = header.split(" ");
if (type !== "blob" || mode === "120000")
throw new Error(`Unsupported git subject resource: ${mode} ${type} ${fullPath}`);
if (fullPath !== fullResource && !fullPath.startsWith(`${fullResource}/`))
throw new Error(`Git subject resource escapes declaration: ${fullPath}`);
const content = spawnSync("git", ["show", `${revision}:${fullPath}`], {
cwd: repoRoot,
encoding: null,
maxBuffer: 16 * 1024 * 1024,
});
if (content.status !== 0) throw new Error(`Unable to read git subject resource: ${revision}:${fullPath}`);
entries.push([root ? fullPath.slice(root.length + 1) : fullPath, "file", sha256(content.stdout)]);
}
}
return resourceIdentity(entries);
}
export function hashGitResources(repoRoot, revision, rootPath, resources) {
return gitResourceIdentity(repoRoot, revision, rootPath, resources).aggregate_sha256;
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |