Skip to content

SIDDARTHA577/envguard-node / .agents/skills/envguard-load-test

envguard-load-test

Verified

Guides capacity planning, workload profile design, local performance benchmarking, and threshold validation without fabricating production metrics or executing unauthorized traffic.

FileKindSize
SKILL.mdskill md7.7 KB
scripts/readiness-auditor.mjsscript27.1 KB
scripts/readiness/adapters/android-adapter.mjsscript30.0 KB
scripts/readiness/adapters/base-adapter.mjsscript4.6 KB
scripts/readiness/adapters/flutter-adapter.mjsscript28.9 KB
scripts/readiness/adapters/generic-adapter.mjsscript15.9 KB
scripts/readiness/adapters/index.mjsscript661 B
scripts/readiness/adapters/ios-adapter.mjsscript21.0 KB
scripts/readiness/adapters/java-spring-adapter.mjsscript39.9 KB
scripts/readiness/adapters/nextjs-react-adapter.mjsscript30.5 KB
scripts/readiness/adapters/node-typescript-adapter.mjsscript115.8 KB
scripts/readiness/adapters/python-adapter.mjsscript44.0 KB
scripts/readiness/adapters/react-native-adapter.mjsscript34.6 KB
scripts/readiness/adapters/registry.mjsscript3.7 KB
scripts/readiness/architecture/applicability.mjsscript21.8 KB
scripts/readiness/architecture/architecture-inventory.mjsscript16.9 KB
scripts/readiness/architecture/architecture-reporter.mjsscript9.4 KB
scripts/readiness/architecture/capacity-model.mjsscript16.9 KB
scripts/readiness/architecture/design-decisions.mjsscript42.0 KB
scripts/readiness/architecture/failure-modes.mjsscript13.3 KB
scripts/readiness/architecture/index.mjsscript895 B
scripts/readiness/architecture/requirements.mjsscript22.0 KB
scripts/readiness/architecture/tradeoffs.mjsscript4.5 KB
scripts/readiness/capacity/benchmark-runner.mjsscript13.4 KB
scripts/readiness/constants.mjsscript6.0 KB
scripts/readiness/deployment/cicd-gate-validator.mjsscript6.1 KB
scripts/readiness/deployment/container-validator.mjsscript10.1 KB
scripts/readiness/deployment/deployment-gate.mjsscript4.8 KB
scripts/readiness/deployment/index.mjsscript411 B
scripts/readiness/deployment/k8s-validator.mjsscript8.8 KB
scripts/readiness/deployment/reliability-validator.mjsscript9.4 KB
scripts/readiness/engine/discovery.mjsscript15.4 KB
scripts/readiness/engine/index.mjsscript341 B
scripts/readiness/engine/orchestrator.mjsscript21.0 KB
scripts/readiness/engine/planner.mjsscript4.2 KB
scripts/readiness/engine/sarif.mjsscript12.7 KB
scripts/readiness/engine/skills-selector.mjsscript10.0 KB
scripts/readiness/execution/git.mjsscript2.3 KB
scripts/readiness/execution/runner.mjsscript11.9 KB
scripts/readiness/index.mjsscript516 B
scripts/readiness/orchestration/engineering-workflow.mjsscript18.5 KB
scripts/readiness/orchestration/index.mjsscript170 B
scripts/readiness/policies/index.mjsscript189 B
scripts/readiness/policies/release-policy.mjsscript9.5 KB
scripts/readiness/remediation/checkpoint-manager.mjsscript34.0 KB
scripts/readiness/remediation/diff-viewer.mjsscript2.5 KB
scripts/readiness/remediation/index.mjsscript778 B
scripts/readiness/remediation/patch-generator.mjsscript17.5 KB
scripts/readiness/remediation/remediation-runner.mjsscript9.9 KB
scripts/readiness/reporters/comparator.mjsscript20.7 KB
scripts/readiness/reporters/index.mjsscript293 B
scripts/readiness/reporters/json-reporter.mjsscript193 B
scripts/readiness/reporters/markdown-reporter.mjsscript18.8 KB
scripts/readiness/validation/evidence-matrix.mjsscript21.5 KB
scripts/readiness/validation/independent-app-runner.mjsscript26.2 KB
scripts/readiness/validation/index.mjsscript328 B

scripts/readiness/engine/discovery.mjs

View on GitHub
import fs from 'node:fs';
import path from 'node:path';
import { spawnSync } from 'node:child_process';
import { IGNORED_DIRECTORIES } from '../constants.mjs';

/**
 * Parses simple workspace glob patterns from package.json or pnpm-workspace.yaml.
 */
function parseWorkspaceGlobs(projectDir) {
  const globs = [];

  // Check pnpm-workspace.yaml
  const pnpmWorkspacePath = path.join(projectDir, 'pnpm-workspace.yaml');
  if (fs.existsSync(pnpmWorkspacePath)) {
    try {
      const content = fs.readFileSync(pnpmWorkspacePath, 'utf8');
      const lines = content.split(/\r?\n/);
      let inPackages = false;
      for (const line of lines) {
        const trimmed = line.trim();
        if (/^packages:\s*$/.test(trimmed)) {
          inPackages = true;
          continue;
        }
        if (inPackages) {
          if (trimmed.startsWith('-')) {
            const pattern = trimmed.replace(/^-\s*['"]?/, '').replace(/['"]?\s*$/, '');
            if (pattern) globs.push(pattern);
          } else if (trimmed && !trimmed.startsWith('#')) {
            inPackages = false;
          }
        }
      }
    } catch { /* ignore non-critical read/parse error */ }
  }

  // Check root package.json workspaces
  const pkgPath = path.join(projectDir, 'package.json');
  if (fs.existsSync(pkgPath)) {
    try {
      const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
      if (Array.isArray(pkg.workspaces)) {
        globs.push(...pkg.workspaces);
      } else if (pkg.workspaces && Array.isArray(pkg.workspaces.packages)) {
        globs.push(...pkg.workspaces.packages);
      }
    } catch { /* ignore non-critical read/parse error */ }
  }

  // Deduplicate globs
  return Array.from(new Set(globs));
}

/**
 * Resolves workspace directories matching glob patterns (e.g. "apps/*", "packages/*").
 */
function resolveWorkspaceDirs(projectDir, globs) {
  const resolved = [];

  for (const glob of globs) {
    if (glob.endsWith('/*') || glob.endsWith('/**')) {
      const parentRel = glob.replace(/\/\*+$/, '');
      const parentAbs = path.join(projectDir, parentRel);
      if (fs.existsSync(parentAbs) && fs.statSync(parentAbs).isDirectory()) {
        try {
          const entries = fs.readdirSync(parentAbs, { withFileTypes: true });
          for (const entry of entries) {
            if (entry.isDirectory() && !IGNORED_DIRECTORIES.has(entry.name)) {
              const rel = path.join(parentRel, entry.name).replace(/\\/g, '/');
              resolved.push(rel);
            }
          }
        } catch { /* ignore non-critical read/parse error */ }
      }
    } else {
      const directAbs = path.join(projectDir, glob);
      if (fs.existsSync(directAbs) && fs.statSync(directAbs).isDirectory()) {
        resolved.push(glob.replace(/\\/g, '/'));
      }
    }
  }

  return Array.from(new Set(resolved));
}

/**
 * Classifies an application based on manifest, structure, and dependencies.
 */
function classifyApplication(appDir, relPath, manifest) {
  const deps = { ...(manifest?.dependencies || {}), ...(manifest?.devDependencies || {}) };
  const languages = [];
  const frameworks = [];
  if (deps['next']) {
    frameworks.push('nextjs');
  }
  if (deps['react']) {
    frameworks.push('react');
  }
  if (deps['express']) {
    frameworks.push('express');
  }
  if (deps['fastify']) {
    frameworks.push('fastify');
  }
  if (deps['@nestjs/core']) {
    frameworks.push('nestjs');
  }
  if (deps['koa']) {
    frameworks.push('koa');
  }
  if (deps['vite']) {
    frameworks.push('vite');
  }

  // Detect mobile frameworks
  const hasExpo = Boolean(deps['expo'] || fs.existsSync(path.join(appDir, 'app.json')) || fs.existsSync(path.join(appDir, 'eas.json')));
  const hasReactNative = Boolean(deps['react-native'] || hasExpo);
  if (hasExpo) frameworks.push('expo');
  if (hasReactNative) frameworks.push('react-native');

  // Detect Flutter
  if (fs.existsSync(path.join(appDir, 'pubspec.yaml'))) {
    languages.push('dart');
    frameworks.push('flutter');
  }

  // Detect Android Native
  const hasAndroidXml =
    fs.existsSync(path.join(appDir, 'AndroidManifest.xml')) ||
    fs.existsSync(path.join(appDir, 'src', 'main', 'AndroidManifest.xml')) ||
    fs.existsSync(path.join(appDir, 'app', 'src', 'main', 'AndroidManifest.xml')) ||
    fs.existsSync(path.join(appDir, 'build.gradle')) ||
    fs.existsSync(path.join(appDir, 'build.gradle.kts'));
  if (hasAndroidXml && !hasReactNative && !frameworks.includes('flutter')) {
    if (!languages.includes('java')) languages.push('java');
    if (!languages.includes('kotlin')) languages.push('kotlin');
    frameworks.push('android-native');
  }

  // Detect iOS Native
  let hasIosProj = fs.existsSync(path.join(appDir, 'Package.swift'));
  if (!hasIosProj) {
    try {
      hasIosProj = fs.readdirSync(appDir).some((f) => f.endsWith('.xcodeproj') || f.endsWith('.xcworkspace'));
    } catch { /* ignore non-critical read/parse error */ }
  }
  if (hasIosProj && !hasReactNative && !frameworks.includes('flutter')) {
    if (!languages.includes('swift')) languages.push('swift');
    frameworks.push('ios-native');
  }

  // Detect databases
  const databases = [];
  if (deps['prisma'] || deps['@prisma/client']) databases.push('prisma');
  if (deps['drizzle-orm']) databases.push('drizzle');
  if (deps['typeorm']) databases.push('typeorm');
  if (deps['mongoose']) databases.push('mongoose');
  if (deps['pg']) databases.push('postgresql');
  if (deps['mysql2'] || deps['mysql']) databases.push('mysql');
  if (deps['sqlite3'] || deps['better-sqlite3']) databases.push('sqlite');

  // Detect languages
  const hasTsConfig = fs.existsSync(path.join(appDir, 'tsconfig.json'));
  if (hasTsConfig || deps['typescript']) {
    languages.push('typescript');
  }
  const hasPkgFile = fs.existsSync(path.join(appDir, 'package.json'));
  let hasJsFiles = Boolean(manifest || hasPkgFile);
  if (!hasJsFiles) {
    try {
      hasJsFiles = fs.readdirSync(appDir).some((f) => /\.(js|mjs|cjs|jsx|ts|tsx)$/i.test(f));
    } catch { /* ignore non-critical read/parse error */ }
  }
  if (hasJsFiles) {
    languages.push('javascript');
  }

  // Detect Python signals
  const pythonManifests = ['pyproject.toml', 'requirements.txt', 'Pipfile', 'setup.py', 'setup.cfg', 'manage.py'];
  const hasPythonManifest = pythonManifests.some((m) => fs.existsSync(path.join(appDir, m)));
  let hasPyFiles = hasPythonManifest;
  if (!hasPyFiles) {
    try {
      hasPyFiles = fs.readdirSync(appDir).some((f) => f.endsWith('.py'));
    } catch { /* ignore non-critical read/parse error */ }
  }
  if (hasPyFiles) {
    languages.push('python');
    let pyManifestContent = '';
    for (const m of ['requirements.txt', 'pyproject.toml', 'Pipfile']) {
      const p = path.join(appDir, m);
      if (fs.existsSync(p)) {
        try {
          pyManifestContent += ' ' + fs.readFileSync(p, 'utf8').toLowerCase();
        } catch { /* ignore non-critical read/parse error */ }
      }
    }
    if (fs.existsSync(path.join(appDir, 'manage.py')) || pyManifestContent.includes('django')) {
      frameworks.push('django');
    }
    if (pyManifestContent.includes('fastapi')) {
      frameworks.push('fastapi');
    }
    if (pyManifestContent.includes('flask')) {
      frameworks.push('flask');
    }
    if (pyManifestContent.includes('sqlalchemy')) {
      databases.push('sqlalchemy');
    }
    if (pyManifestContent.includes('tortoise-orm')) {
      databases.push('tortoise');
    }
  }

  // Detect Java / Kotlin signals
  const javaManifests = ['pom.xml', 'build.gradle', 'build.gradle.kts', 'settings.gradle', 'settings.gradle.kts'];
  const hasJavaManifest = javaManifests.some((m) => fs.existsSync(path.join(appDir, m)));
  let hasJavaFiles = hasJavaManifest;
  if (!hasJavaFiles) {
    try {
      hasJavaFiles = fs.readdirSync(appDir).some((f) => f.endsWith('.java') || f.endsWith('.kt'));
    } catch { /* ignore non-critical read/parse error */ }
  }
  if (hasJavaFiles) {
    languages.push('java');
    let javaDescriptorContent = '';
    for (const m of ['pom.xml', 'build.gradle', 'build.gradle.kts']) {
      const p = path.join(appDir, m);
      if (fs.existsSync(p)) {
        try {
          javaDescriptorContent += ' ' + fs.readFileSync(p, 'utf8').toLowerCase();
        } catch { /* ignore non-critical read/parse error */ }
      }
    }
    if (javaDescriptorContent.includes('spring-boot') || javaDescriptorContent.includes('org.springframework.boot')) {
      frameworks.push('spring-boot');
    }
    if (javaDescriptorContent.includes('spring-boot-starter-data-jpa') || javaDescriptorContent.includes('hibernate')) {
      databases.push('jpa-hibernate');
    }
    if (javaDescriptorContent.includes('flyway')) {
      databases.push('flyway');
    }
    if (javaDescriptorContent.includes('liquibase')) {
      databases.push('liquibase');
    }
  }

  // Detect deployment targets
  const deploymentTargets = [];
  if (
    fs.existsSync(path.join(appDir, 'Dockerfile')) ||
    fs.existsSync(path.join(appDir, 'docker-compose.yml')) ||
    fs.existsSync(path.join(appDir, 'Containerfile'))
  ) {
    deploymentTargets.push('docker');
  }
  if (fs.existsSync(path.join(appDir, 'vercel.json'))) {
    deploymentTargets.push('vercel');
  }
  if (fs.existsSync(path.join(appDir, 'netlify.toml'))) {
    deploymentTargets.push('netlify');
  }

  // Determine application type
  let type;
  let confidence = 'verified';
  let uncertaintyReason = null;

  const isMobile =
    frameworks.includes('expo') ||
    frameworks.includes('react-native') ||
    frameworks.includes('flutter') ||
    frameworks.includes('android-native') ||
    frameworks.includes('ios-native');

  if (!manifest) {
    if (isMobile) {
      type = 'mobile';
      confidence = 'verified';
    } else if (languages.includes('python')) {
      if (frameworks.includes('django') || frameworks.includes('fastapi') || frameworks.includes('flask')) {
        type = 'backend';
        confidence = 'verified';
      } else {
        type = 'backend';
        confidence = 'inferred';
      }
    } else if (languages.includes('java')) {
      if (frameworks.includes('spring-boot')) {
        type = 'backend';
        confidence = 'verified';
      } else {
        type = 'backend';
        confidence = 'inferred';
      }
    } else {
      type = 'unknown';
      confidence = 'uncertain';
      uncertaintyReason = 'No package.json manifest found in application directory.';
    }
  } else if (isMobile) {
    type = 'mobile';
    confidence = 'verified';
  } else if (frameworks.includes('nextjs')) {
    // Next.js with app/api or pages/api can be fullstack
    const hasApiRoutes =
      fs.existsSync(path.join(appDir, 'app', 'api')) ||
      fs.existsSync(path.join(appDir, 'src', 'app', 'api')) ||
      fs.existsSync(path.join(appDir, 'pages', 'api')) ||
      fs.existsSync(path.join(appDir, 'src', 'pages', 'api'));
    type = hasApiRoutes ? 'fullstack' : 'frontend';
  } else if (frameworks.includes('react') || frameworks.includes('vite')) {
    type = 'frontend';
  } else if (
    frameworks.includes('express') ||
    frameworks.includes('fastify') ||
    frameworks.includes('nestjs') ||
    frameworks.includes('koa')
  ) {
    type = 'backend';
  } else if (manifest.bin) {
    type = 'cli';
  } else if (
    manifest.main ||
    manifest.types ||
    manifest.exports ||
    relPath.includes('packages/') ||
    relPath.includes('shared') ||
    relPath.includes('lib')
  ) {
    type = 'library';
  } else if (manifest.scripts?.start || manifest.scripts?.dev) {
    type = 'service';
    confidence = 'inferred';
  } else {
    type = 'unknown';
    confidence = 'uncertain';
    uncertaintyReason = 'Package manifest present but no recognized framework, library, or entrypoint pattern found.';
  }

  // Check router architecture for Next.js
  let nextRouter = null;
  if (frameworks.includes('nextjs')) {
    const hasApp = fs.existsSync(path.join(appDir, 'app')) || fs.existsSync(path.join(appDir, 'src', 'app'));
    const hasPages = fs.existsSync(path.join(appDir, 'pages')) || fs.existsSync(path.join(appDir, 'src', 'pages'));
    if (hasApp && hasPages) nextRouter = 'hybrid';
    else if (hasApp) nextRouter = 'app_router';
    else if (hasPages) nextRouter = 'pages_router';
  }

  return {
    type,
    confidence,
    uncertaintyReason,
    frameworks,
    databases,
    languages,
    deploymentTargets,
    nextRouter,
  };
}

/**
 * Builds a comprehensive inventory graph for the repository.
 * Model: Repository -> Applications -> Services -> Frameworks -> Databases -> Deployment Targets.
 */
export function buildInventoryGraph(projectDir) {
  const repoName = path.basename(projectDir);

  // Check Git status
  let isGit = false;
  let gitCommit = null;
  try {
    const res = spawnSync('git', ['rev-parse', 'HEAD'], {
      cwd: projectDir,
      encoding: 'utf8',
      timeout: 3000,
      shell: false,
    });
    if (res.status === 0 && res.stdout.trim()) {
      isGit = true;
      gitCommit = res.stdout.trim();
    }
  } catch { /* ignore non-critical read/parse error */ }

  // Check Monorepo signals
  const workspaceGlobs = parseWorkspaceGlobs(projectDir);
  const isMonorepo = workspaceGlobs.length > 0;
  let monorepoType = null;
  if (fs.existsSync(path.join(projectDir, 'pnpm-workspace.yaml'))) {
    monorepoType = 'pnpm';
  } else if (workspaceGlobs.length > 0) {
    monorepoType = 'npm-yarn';
  }

  const applications = [];
  const relationships = [];

  if (isMonorepo) {
    const appRelDirs = resolveWorkspaceDirs(projectDir, workspaceGlobs);
    for (const relPath of appRelDirs) {
      const appAbs = path.join(projectDir, relPath);
      let manifest = null;
      const pkgPath = path.join(appAbs, 'package.json');
      if (fs.existsSync(pkgPath)) {
        try {
          manifest = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
        } catch { /* ignore non-critical read/parse error */ }
      }

      const classification = classifyApplication(appAbs, relPath, manifest);
      const appId = manifest?.name || path.basename(relPath);

      applications.push({
        id: appId,
        name: manifest?.name || path.basename(relPath),
        path: relPath,
        absPath: appAbs,
        isRoot: false,
        manifest,
        ...classification,
      });
    }

    // Map relationships between applications (e.g. web consumes shared library)
    for (const app of applications) {
      if (!app.manifest) continue;
      const allDeps = {
        ...(app.manifest.dependencies || {}),
        ...(app.manifest.devDependencies || {}),
      };

      for (const other of applications) {
        if (other.id === app.id) continue;
        if (allDeps[other.name] || allDeps[other.id]) {
          relationships.push({
            from: app.id,
            to: other.id,
            type: other.type === 'library' ? 'depends_on' : 'consumes',
          });
        }
      }
    }
  } else {
    // Single project repository
    let manifest = null;
    const pkgPath = path.join(projectDir, 'package.json');
    if (fs.existsSync(pkgPath)) {
      try {
        manifest = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
      } catch { /* ignore non-critical read/parse error */ }
    }

    const classification = classifyApplication(projectDir, '.', manifest);
    applications.push({
      id: manifest?.name || repoName,
      name: manifest?.name || repoName,
      path: '.',
      absPath: projectDir,
      isRoot: true,
      manifest,
      ...classification,
    });
  }

  return {
    repository: {
      root: projectDir,
      name: repoName,
      isGit,
      gitCommit,
      isMonorepo,
      monorepoType,
      workspaceGlobs,
    },
    applications,
    relationships,
    timestamp: new Date().toISOString(),
  };
}
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 319kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 319kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 319kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 196kUpdated Claude CodeCodexVerifiedInstall