SIDDARTHA577/envguard-node / .agents/skills/envguard-senior-engineer-review
envguard-senior-engineer-review
VerifiedFlagship senior software architect review coordinating full-stack discovery, system design assessment, multi-adapter verification, capacity planning, SRE reliability analysis, and ADR generation.
scripts/readiness/remediation/diff-viewer.mjs
View on GitHub/**
* Dependency-free Unified Diff Generator for EnvGuard reviewable fixes.
* Produces standard unidiff strings suitable for CLI preview and patch review.
*
* @param {string} filePath - Relative file path being diffed
* @param {string|null} originalContent - Original file content (or null if new file)
* @param {string} proposedContent - Proposed modified content
* @returns {string} Standard unified diff string
*/
export function generateUnifiedDiff(filePath, originalContent, proposedContent) {
const isNewFile = originalContent === null || originalContent === undefined;
const splitLines = (text) => {
if (text === null || text === undefined || text === '') return [];
const normalized = String(text).replace(/\r\n/g, '\n');
const lines = normalized.split('\n');
if (lines.length > 0 && lines[lines.length - 1] === '') {
lines.pop();
}
return lines;
};
const origLines = isNewFile ? [] : splitLines(originalContent);
const propLines = splitLines(proposedContent);
const oldHeader = isNewFile ? '/dev/null' : `a/${filePath}`;
const newHeader = `b/${filePath}`;
let diff = `--- ${oldHeader}\n+++ ${newHeader}\n`;
if (isNewFile) {
diff += `@@ -0,0 +1,${propLines.length} @@\n`;
for (const line of propLines) {
diff += `+${line}\n`;
}
return diff;
}
// Simple, deterministic unified hunk generation
const hunks = [];
let i = 0;
let j = 0;
// Find differing regions
while (i < origLines.length || j < propLines.length) {
if (i < origLines.length && j < propLines.length && origLines[i] === propLines[j]) {
i++;
j++;
} else {
const startOrig = i;
const startProp = j;
const removed = [];
const added = [];
while (i < origLines.length && (j >= propLines.length || origLines[i] !== propLines[j])) {
removed.push(origLines[i]);
i++;
}
while (j < propLines.length && (i >= origLines.length || origLines[i] !== propLines[j])) {
added.push(propLines[j]);
j++;
}
hunks.push({
origStart: startOrig + 1,
origCount: removed.length,
propStart: startProp + 1,
propCount: added.length,
removed,
added,
});
}
}
if (hunks.length === 0) {
return `${diff}@@ -1 +1 @@\n (No changes)\n`;
}
for (const h of hunks) {
diff += `@@ -${h.origStart},${h.origCount} +${h.propStart},${h.propCount} @@\n`;
for (const r of h.removed) {
diff += `-${r}\n`;
}
for (const a of h.added) {
diff += `+${a}\n`;
}
}
return diff;
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |