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/execution/git.mjs
View on GitHubimport { spawnSync } from 'node:child_process';
import process from 'node:process';
import { buildSanitizedEnv } from './runner.mjs';
/**
* Checks whether a given relative file path is tracked by Git.
* Returns an object with isGitRepo and isTracked status.
*/
export function checkGitTracking(projectDir, filePath) {
try {
const res = spawnSync('git', ['ls-files', '--error-unmatch', filePath], {
cwd: projectDir,
encoding: 'utf8',
timeout: 3000,
env: buildSanitizedEnv(process.env),
shell: false,
});
return {
isGitRepo: res.status === 0 || !res.stderr?.includes('not a git repository'),
isTracked: res.status === 0,
};
} catch {
return { isGitRepo: false, isTracked: false };
}
}
/**
* Parses .gitignore file content into structured match rules.
* Supports comments, blank lines, directory markers, and negation rules (!pattern).
*/
export function parseGitignoreRules(gitignoreContent) {
if (typeof gitignoreContent !== 'string') return [];
const rules = [];
const lines = gitignoreContent.split(/\r?\n/);
for (const rawLine of lines) {
const line = rawLine.trim();
if (!line || line.startsWith('#')) continue;
const isNegation = line.startsWith('!');
const pattern = isNegation ? line.slice(1).trim() : line;
rules.push({
pattern,
isNegation,
});
}
return rules;
}
/**
* Converts a gitignore glob pattern to a RegExp.
* Properly escapes regex metacharacters including backslashes to avoid CodeQL sanitization alerts.
*/
function globToRegex(pattern) {
let pat = pattern;
if (pat.startsWith('/')) pat = pat.slice(1);
if (pat.endsWith('/')) pat = pat.slice(0, -1);
const escaped = pat.replace(/[\\^$+?.()|[\]{}]/g, '\\$&').replace(/\*/g, '.*');
return new RegExp(`(^|/)${escaped}(/|$)`);
}
/**
* Evaluates whether a relative file path is matched by parsed .gitignore rules.
* Processes rules in order, properly handling negation rules.
*/
export function isPathIgnoredByRules(rules, filePath) {
if (!Array.isArray(rules) || rules.length === 0) return false;
const normalized = filePath.replace(/\\/g, '/');
let ignored = false;
for (const rule of rules) {
const rx = globToRegex(rule.pattern);
if (rx.test(normalized)) {
ignored = !rule.isNegation;
}
}
return ignored;
}
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 |