mvschwarz/openrig / packages/daemon/specs/agents/shared/skills/core/openrig-upgrade
openrig-upgrade
VerifiedUse when an agent is preparing or performing an OpenRig CLI/daemon upgrade and must preserve live seats, verify each mutation, or reconcile managed plugin and skill files without overwriting local work.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 12.1 KB |
| scripts/backup-sqlite.mjs | script | 4.6 KB |
| scripts/inspect-upgrade.mjs | script | 1.5 KB |
| scripts/migrate-telemetry-state-0.5.9.mjsexecutable | script | 60.1 KB |
| scripts/refresh-managed-plugin.mjs | script | 5.3 KB |
scripts/refresh-managed-plugin.mjs
View on GitHub#!/usr/bin/env node
import crypto from "node:crypto";
import fs from "node:fs";
import path from "node:path";
function argument(name) {
const index = process.argv.indexOf(name);
return index === -1 ? undefined : process.argv[index + 1];
}
function fail(message, next) {
process.stderr.write(`${JSON.stringify({ ok: false, error: message, next }, null, 2)}\n`);
process.exit(1);
}
function inventory(root) {
const files = new Map();
if (!fs.existsSync(root)) return files;
function walk(directory, prefix = "") {
for (const entry of fs.readdirSync(directory, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
const absolute = path.join(directory, entry.name);
if (entry.isDirectory()) {
walk(absolute, relative);
} else if (entry.isFile()) {
files.set(relative, {
kind: "file",
hash: crypto.createHash("sha256").update(fs.readFileSync(absolute)).digest("hex"),
mode: fs.statSync(absolute).mode & 0o777,
});
} else {
files.set(relative, { kind: "unsupported" });
}
}
}
walk(root);
return files;
}
// Equality is the COMPLETE inventoried state, not just the bytes. Mode is a
// local modification like any other: an operator who chmods a managed file has
// changed it, and comparing only the hash classifies that file refresh-safe and
// then chmods it back to the packaged mode. The inventory already carries mode;
// dropping the axis here is what let the write through.
function same(left, right) {
return left?.kind === "file"
&& right?.kind === "file"
&& left.hash === right.hash
&& left.mode === right.mode;
}
function hasNonDirectoryLiveAncestor(relative, live) {
const parts = relative.split("/");
return parts.slice(0, -1).some((_, index) => (
live.has(parts.slice(0, index + 1).join("/"))
));
}
function classify(ancestor, target, live) {
if ([ancestor, target, live].some((item) => item?.kind === "unsupported")) return "preserve-unsupported-type";
if (target && live && same(target, live)) return "current";
if (ancestor && target && live && same(ancestor, live)) return "refresh-safe";
if (!ancestor && target && !live) return "add-safe";
if (ancestor && target && live) return "preserve-local-modification";
if (ancestor && target && !live) return "preserve-local-deletion";
if (!ancestor && !target && live) return "preserve-live-only";
if (ancestor && !target && live) return "preserve-target-removal";
if (!ancestor && target && live) return "preserve-unproven-existing";
return "preserve-unclassified";
}
function atomicCopy(source, destination, mode) {
fs.mkdirSync(path.dirname(destination), { recursive: true });
const temporary = `${destination}.openrig-refresh-${process.pid}-${crypto.randomBytes(4).toString("hex")}`;
try {
fs.copyFileSync(source, temporary, fs.constants.COPYFILE_EXCL);
fs.chmodSync(temporary, mode);
fs.renameSync(temporary, destination);
} finally {
fs.rmSync(temporary, { force: true });
}
}
const ancestorArg = argument("--ancestor");
const targetArg = argument("--target");
const liveArg = argument("--live");
const applySafe = process.argv.includes("--apply-safe");
if (!ancestorArg || !targetArg || !liveArg) {
fail("--ancestor, --target, and --live are required", "derive all three plugin roots before classifying any managed file");
}
const roots = {
ancestor: path.resolve(ancestorArg),
target: path.resolve(targetArg),
live: path.resolve(liveArg),
};
for (const name of ["ancestor", "target"]) {
if (!fs.existsSync(roots[name]) || !fs.statSync(roots[name]).isDirectory()) {
fail(`${name} is not a directory: ${roots[name]}`, `derive the ${name} packaged plugin root before retrying`);
}
}
if (fs.existsSync(roots.live) && !fs.statSync(roots.live).isDirectory()) {
fail(`live is not a directory: ${roots.live}`, "do not replace a non-directory live path automatically");
}
const inventories = {
ancestor: inventory(roots.ancestor),
target: inventory(roots.target),
live: inventory(roots.live),
};
const paths = [...new Set([
...inventories.ancestor.keys(),
...inventories.target.keys(),
...inventories.live.keys(),
])].sort();
const actions = paths.map((relative) => ({
path: relative,
decision: hasNonDirectoryLiveAncestor(relative, inventories.live)
? "preserve-unsupported-type"
: classify(
inventories.ancestor.get(relative),
inventories.target.get(relative),
inventories.live.get(relative),
),
}));
const written = [];
if (applySafe) {
for (const action of actions) {
if (action.decision !== "refresh-safe" && action.decision !== "add-safe") continue;
const target = inventories.target.get(action.path);
atomicCopy(path.join(roots.target, action.path), path.join(roots.live, action.path), target.mode);
written.push(action.path);
}
}
const preserved = actions.filter((action) => action.decision.startsWith("preserve-"));
process.stdout.write(`${JSON.stringify({
schema: "openrig-managed-plugin-refresh/v1",
roots,
applied: applySafe,
complete: preserved.length === 0,
written,
actions,
next: preserved.length === 0
? "re-run the plan after the surrounding upgrade step and verify the live tree"
: "resolve preserved paths individually; this helper will not delete or overwrite them",
}, null, 2)}\n`);
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: 463k | Updated | Claude CodeCodex | Verified | 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: 463k | Updated | Claude CodeCodex | Verified | Install |
| discernment-nudgeanthropics/skillsAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals, or emails, estimates or projections, analysis or interpretation of data, factual claims they may rely on, or a multi-step argument — invoke this skill BEFORE finalizing your reply and then, if it applies, append 2-3 short follow-up questions, each tied to something specific in what you just produced, that help the user check key facts, probe the reasoning or assumptions, and notice missing context. Do this at most once per conversation. Skip it when the user asked a trivial how-to or simple lookup, wants a purely educational explanation, asked you only to format, convert, or assemble a file from content they provided, is writing code they will run, is doing creative writing or casual chat, or already asked you to double-check, cite, or review — the skill file explains these boundaries and the exact output format. | Stars: 195k | Updated | Claude CodeCodex | Verified | Install |
| internal-commsanthropics/skillsA set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill whenever asked to write some sort of internal communications (status reports, leadership updates, 3P updates, company newsletters, FAQs, incident reports, project updates, etc.). | Stars: 195k | Updated | Claude CodeCodex | Verified | Install |