{
  "audit_id": "aud_20261124_b5886e8",
  "commit_sha": "f0bcc08ab07d2dff2415fa40fb26d07eaf55b4ff",
  "scanner_digests": {
    "trivy": "sha256:8f6bb947dbc528902e11f2f5be52f7b519f6a39d5d148f41166f2040499768fb",
    "osv_scanner": "sha256:a70ffffc2bfd33482953e5d6b64c6fcdb30239717a07b0f0d3ab2859ce3e4cde",
    "semgrep": "sha256:67518c174185a2043fdbed16c70631b79209499b3671178e7194379b48295a0d",
    "trufflehog": "sha256:8fd07ea46a3f59583c4d50f006d8cf150530141b28969c3c34cc455cb9165a6b"
  },
  "metrics": {
    "loc_total": 64827,
    "direct_dependencies": 8,
    "transitive_dependencies": 75,
    "has_lockfile": true,
    "has_test_files": true,
    "test_file_count": 370,
    "license_osi_approved": true
  },
  "findings": {
    "cve_critical": [],
    "cve_high": [],
    "secrets_verified": [],
    "secrets_production": [],
    "secrets_test_fixtures": [
      {
        "id": "ST-SEC-001",
        "rule_id": "SSH_PRIVATE_KEY",
        "file": "tests/core/security/workers/securityCheckWorker.test.ts",
        "line": 29,
        "secret_hash": "-----*...",
        "severity": "LOW"
      },
      {
        "id": "ST-SEC-002",
        "rule_id": "GITHUB_PAT",
        "file": "tests/core/security/workers/securityCheckWorker.test.ts",
        "line": 16,
        "secret_hash": "***_**...",
        "severity": "LOW"
      }
    ],
    "suspicious_install_hooks": [],
    "sast_blocking": [],
    "iac_misconfigs": []
  },
  "sanitized_excerpts": [
    {
      "excerpt_id": "EX-001",
      "file": "src/cli/cliRun.ts",
      "lines": "1-80",
      "content": "import * as fs from 'node:fs/promises';\nimport path from 'node:path';\nimport process from 'node:process';\nimport { type Command, Option, program } from 'commander';\nimport pc from 'picocolors';\nimport { getVersion } from '../core/file/packageJsonParse.js';\nimport type { checkRemoteRepoExists } from '../core/git/gitRemoteHandle.js';\nimport { isExplicitRemoteUrl, isValidShorthand } from '../core/git/gitRemoteUrl.js';\nimport { handleError, RepomixError } from '../shared/errorHandle.js';\nimport { logger, repomixLogLevels } from '../shared/logger.js';\nimport { parseHumanSizeToBytes } from '../shared/sizeParse.js';\nimport type { RepomixProgressCallback } from '../shared/types.js';\nimport { redactOptionsForLog, redactUrl } from '../shared/urlRedact.js';\nimport type { runDefaultAction } from './actions/defaultAction.js';\nimport type { runInitAction } from './actions/initAction.js';\nimport type { runMcpAction } from './actions/mcpAction.js';\nimport type { runRemoteAction } from './actions/remoteAction.js';\nimport type { runVersionAction } from './actions/versionAction.js';\nimport type { runWatchAction } from './actions/watchAction.js';\nimport type { CliOptions } from './types.js';\n\n// Semantic mapping for CLI suggestions\n// This maps conceptually related terms (not typos) to valid options\nconst semanticSuggestionMap: Record<string, string[]> = {\n  exclude: ['--ignore'],\n  reject: ['--ignore'],\n  omit: ['--ignore'],\n  skip: ['--ignore'],\n  blacklist: ['--ignore'],\n  save: ['--output'],\n  export: ['--output'],\n  out: ['--output'],\n  file: ['--output'],\n  format: ['--style'],\n  type: ['--style'],\n  syntax: ['--style'],\n  debug: ['--verbose'],\n  detailed: ['--verbose'],\n  silent: ['--quiet'],\n  mute: ['--quiet'],\n  add: ['--include'],\n  with: ['--include'],\n  whitelist: ['--include'],\n  clone: ['--remote'],\n  git: ['--remote'],\n  minimize: ['--compress'],\n  reduce: ['--compress'],\n  'strip-comments': ['--remove-comments'],\n  'no-comments': ['--remove-comments'],\n  print: ['--stdout'],\n  console: ['--stdout'],\n  terminal: ['--stdout'],\n  pipe: ['--stdin'],\n  monitor: ['--watch'],\n  live: ['--watch'],\n  auto: ['--watch'],\n};\n\ntype OutputErrorHandler = (str: string, write: (str: string) => void) => void;\n\n/**\n * Wraps Commander's error output so an unknown option with a semantic match\n * (e.g. `--exclude`) prints a \"Did you mean\" hint instead of the raw error.\n */\nexport const createOutputErrorHandler =\n  (originalOutputError: OutputErrorHandler): OutputErrorHandler =>\n  (str, write) => {\n    // Check if this is an unknown option error\n    if (str.includes('unknown option')) {\n      const match = str.match(/unknown option '?(-{1,2}[^ ']+)'?/i);\n      if (match?.[1]) {\n        const unknownOption = match[1];\n        const cleanOption = unknownOption.replace(/^-+/, '');\n\n        // Check if the option has a semantic match\n        const semanticMatches = semanticSuggestionMap[cleanOption];\n        if (semanticMatches) {\n          // We have a direct semantic match\n          logger.error(`\u2716 Unknown option: ${unknownOption}`);\n          logger.info(`Did you mean: ${semanticMatches.join(' or ')}?`);"
    },
    {
      "excerpt_id": "EX-002",
      "file": "src/cli/types.ts",
      "lines": "1-80",
      "content": "import type { OptionValues } from 'commander';\nimport type { OutputPattern, RepomixOutputFilePathStyle, RepomixOutputStyle } from '../config/configSchema.js';\n\nexport interface CliOptions extends OptionValues {\n  // Basic Options\n  version?: boolean;\n\n  // Output Options\n  output?: string;\n  stdout?: boolean;\n  style?: RepomixOutputStyle;\n  outputFilePathStyle?: RepomixOutputFilePathStyle;\n  parsableStyle?: boolean;\n  compress?: boolean;\n  // Internal: per-file inclusion levels (output.patterns). Not exposed as a CLI flag;\n  // set programmatically by the MCP tools so an agent can build a packing scenario per call.\n  outputPatterns?: OutputPattern[];\n  outputShowLineNumbers?: boolean;\n  copy?: boolean;\n  fileSummary?: boolean;\n  directoryStructure?: boolean;\n  files?: boolean;\n  removeComments?: boolean;\n  removeEmptyLines?: boolean;\n  truncateBase64?: boolean;\n  headerText?: string;\n  instructionFilePath?: string;\n  includeEmptyDirectories?: boolean;\n  includeFullDirectoryStructure?: boolean;\n  splitOutput?: number; // bytes\n  gitSortByChanges?: boolean;\n  includeDiffs?: boolean;\n  includeLogs?: boolean;\n  includeLogsCount?: number;\n\n  // Filter Options\n  include?: string;\n  ignore?: string;\n  gitignore?: boolean;\n  dotIgnore?: boolean;\n  defaultPatterns?: boolean;\n  stdin?: boolean;\n\n  // Remote Repository Options\n  remote?: string;\n  remoteBranch?: string;\n  remoteTrustConfig?: boolean;\n  skipLocalConfig?: boolean; // Internal flag: skip loading config files from the working directory (e.g., untrusted remote repos)\n  skipGlobalConfig?: boolean; // Internal flag: also skip the operator's GLOBAL repomix config. Untrusted-agent contexts (--sandbox) set this because a config-driven output.instructionFilePath could read an out-of-workspace file into agent-visible output.\n  confineToBaseDir?: boolean; // Internal flag: drop any discovered file that resolves outside the base directory. Off by default (so documented ../ / absolute include patterns keep working); untrusted-agent contexts (--sandbox) set it as a syntax-agnostic escape backstop.\n  skipMigration?: boolean; // Internal flag: never run the Repopack migration (e.g., a throwaway remote clone whose legacy files are attacker-controlled)\n  enableFileProcessors?: boolean; // Internal flag: allow input.processors to run external commands. Injected only by the real CLI entry point (auto-on for local runs; gated by --remote-trust-config for remote)\n  deferTokenBudgetCheck?: boolean; // Internal flag: skip the token-budget check inside runDefaultAction so the caller can enforce it after delivering output (e.g., remote runs copy out of the temp dir first)\n  signal?: AbortSignal; // Internal: cancels the run (download/clone and pack). Set programmatically by the MCP tools from the request's abort signal\n\n  // Configuration Options\n  config?: string;\n  init?: boolean;\n  global?: boolean;\n\n  // Security Options\n  securityCheck?: boolean;\n\n  // Token Count Options\n  tokenCountEncoding?: string;\n  tokenCountTree?: boolean | number;\n  tokenBudget?: number;\n\n  // MCP\n  mcp?: boolean;\n  sandbox?: boolean | string;\n\n  // Skill Generation\n  skillGenerate?: string | boolean;\n  skillName?: string; // Pre-computed skill name (used internally for remote repos)\n  skillDir?: string; // Pre-computed skill directory (used internally for remote repos)\n  skillProjectName?: string; // Project name for generated skill descriptions\n  skillSourceUrl?: string; // Source URL for skill (used internally for remote repos only)\n  skillOutput?: string; // Output path for skill (skips location prompt)\n  force?: boolean; // Skip all confirmation prompts"
    },
    {
      "excerpt_id": "EX-003",
      "file": "src/cli/cliTokenBudget.ts",
      "lines": "1-22",
      "content": "import { RepomixError } from '../shared/errorHandle.js';\n\n/**\n * Throws a RepomixError when the packed output exceeds the configured token budget.\n * A no-op when no budget is set (undefined) or the total is within budget.\n *\n * Enforced by the top-level CLI flow (runCli) after the chosen action has fully\n * produced and delivered its output \u2014 written locally, or copied out of the\n * remote temp directory. This makes it a guard that fails the run with a\n * non-zero exit code (not an in-pack fail-fast), behaving consistently for both\n * local and --remote runs.\n */\nexport const validateTokenBudget = (totalTokens: number, tokenBudget: number | undefined): void => {\n  if (tokenBudget === undefined || totalTokens <= tokenBudget) {\n    return;\n  }\n\n  throw new RepomixError(\n    `Packed output exceeds the token budget: ${totalTokens.toLocaleString()} > ${tokenBudget.toLocaleString()} tokens. ` +\n      'Reduce the output with --compress, narrow the scope with --include/--ignore, or raise --token-budget.',\n  );\n};"
    },
    {
      "excerpt_id": "EX-004",
      "file": "src/cli/cliSpinner.ts",
      "lines": "1-48",
      "content": "import { Spinner as PicoSpinner, renderer } from 'picospinner';\nimport type { CliOptions } from './types.js';\n\nexport class Spinner {\n  private spinner: PicoSpinner | null;\n\n  constructor(\n    message: string,\n    cliOptions?: CliOptions,\n    deps = {\n      PicoSpinner,\n    },\n  ) {\n    // If the user has specified the verbose flag, don't show the spinner\n    // Use optional chaining to handle undefined cliOptions (e.g., in bundled worker environments)\n    const isQuiet = cliOptions?.quiet || cliOptions?.verbose || cliOptions?.stdout || false;\n    this.spinner = isQuiet ? null : new deps.PicoSpinner(message);\n  }\n\n  start(): void {\n    // In child processes (Tinypool, stdio: \"pipe\"), process.stdout is not a TTY,\n    // so PicoSpinner cannot detect terminal width via getWindowSize().\n    // Fall back to COLUMNS env var passed from the main process.\n    if (!process.stdout.getWindowSize && process.env.COLUMNS) {\n      const columns = Number(process.env.COLUMNS);\n      if (columns > 0) {\n        // Accessing a private property to work around the child process limitation\n        (renderer as unknown as { terminalWidth: number }).terminalWidth = columns;\n      }\n    }\n    this.spinner?.start();\n  }\n\n  update(message: string): void {\n    // Use render=false to avoid immediate re-rendering on every progress callback.\n    // The spinner's internal tick interval will pick up the latest text on the next frame,\n    // similar to how the previous log-update implementation worked.\n    this.spinner?.setText(message, false);\n  }\n\n  succeed(message: string): void {\n    this.spinner?.succeed(message);\n  }\n\n  fail(message: string): void {\n    this.spinner?.fail(message);\n  }\n}"
    },
    {
      "excerpt_id": "ST-METRIC-LOC",
      "file": "METRICS",
      "lines": "LOC: 64827",
      "content": "Verified total codebase lines of code: 64827"
    },
    {
      "excerpt_id": "ST-METRIC-TESTS",
      "file": "METRICS",
      "lines": "TestFiles: 370",
      "content": "Verified automated test file count: 370 (has_test_files=True)"
    },
    {
      "excerpt_id": "ST-METRIC-DEPS",
      "file": "METRICS",
      "lines": "Dependencies: 8",
      "content": "Verified dependencies: direct=8, transitive=75"
    }
  ]
}