Reading output

Reports

Understand analyzer JSON, doctor warnings, unresolved import diagnostics, and explain-export reports.

Analysis JSON

The normal JSON report is the compact machine-readable surface for automation. Use it to gate CI or drive cleanup review, then switch to verbose JSON only when you need config and discovery diagnostics.

{
  "issues": {
    "files": { "src/legacy/dead-view.ts": {} },
    "exports": {
      "src/constants.ts": {
        "oldFlag": { "symbol": "oldFlag", "line": 4, "col": 14 }
      }
    },
    "unresolved": {}
  },
  "counters": {
    "files": 1,
    "exports": 1,
    "unresolved": 0,
    "processed": 42,
    "total": 42
  }
}

Doctor Output

Doctor returns a summary, sorted warning list, and sampled unresolved import diagnostics. It exits with findings when warnings or unresolved diagnostics are present, but it never edits files.

{
  "warnings": [
    {
      "code": "entryGlobZeroMatches",
      "message": "entry pattern \"src/app/**/*.tsx\" matched no project files"
    }
  ],
  "summary": {
    "version": "0.4.13",
    "configPath": "codescythe.jsonc",
    "projectCount": 184,
    "entryCount": 2,
    "ignoredUnresolvedCount": 0,
    "ignoredUnresolvedPatterns": ["*.svg?raw"],
    "packageImportKeys": ["#app/*"],
    "configuredAliasKeys": ["#generated/*"]
  }
}
warnings
Config risk list

TypeConfigDoctorWarning[]

ValuesEach item has code and message.

Treat every warning as a config review item before widening scope or forcing a fix.

summary.projectCount
Project file count

Typenumber

ValuesCount after project, ignore, and gitignore filtering.

A very high count with a tiny entry count often means project is too broad for the current entries.

summary.entryCount
Matched entry count

Typenumber

ValuesCount of entry files that matched project files.

Zero entries means analysis cannot establish reachability from the configured roots.

summary.ignoredUnresolvedPatterns
Ignored resolver patterns

Typestring[]

ValuesPatterns from unresolvedImports.ignore.

Broad JS/TS-family source patterns should be reviewed with extra care because they can hide real usage.

summary.packageImportKeys
Package import aliases

Typestring[]

ValuesKeys discovered from package metadata.

Useful when source alias overlap makes unresolved ignore rules risky.

summary.configuredAliasKeys
Config aliases

Typestring[]

ValuesKeys from aliases in Codescythe config.

If an ignored unresolved import overlaps one of these, resolve before ignore.

Doctor Warning Codes

entryGlobZeroMatches
Entry matched nothing

Typewarning code

ValuesEmitted per entry pattern.

Fix the path, widen project, or remove the stale entry. A zero-match entry cannot keep anything reachable.

unresolvedImports
Analysis has unresolved imports

Typewarning code

ValuesEmitted when analysis reported unresolved import edges.

Use the unresolved diagnostics section to inspect resolver errors and alias candidate files.

sourceAliasUnresolvedIgnore
Ignore overlaps source alias

Typewarning code

ValuesEmitted for unresolvedImports.ignore patterns that may match local aliases.

This is the main resolve-before-ignore warning. Fix mode can refuse risky source-like patterns unless forced.

projectScopeMuchBroaderThanEntryCoverage
Project likely too broad

Typewarning code

ValuesEmitted when most project files are unused from current entries.

Add missing entries or narrow project before trusting a large deletion report.

ignoredGeneratedPatternMatchesSource
Generated ignore catches source

Typewarning code

ValuesEmitted when an ignore pattern containing generated also matches checked source.

Narrow generated ignores so they do not mask hand-written code.

Unresolved Diagnostics

Doctor samples unresolved imports and asks the resolver to explain what it tried. Use this section to decide whether an import is a real missing file, an alias mapping gap, or a safe non-source asset.

{
  "unresolvedImports": [
    {
      "importer": "src/routes/home.tsx",
      "specifier": "#generated/client",
      "resolverError": "module not found",
      "matchedAliases": [
        {
          "source": "config",
          "key": "#generated/*",
          "target": "src/generated/*",
          "expandedTarget": "src/generated/client",
          "candidateFiles": [
            {
              "path": "src/generated/client.ts",
              "exists": false,
              "inProject": false
            }
          ]
        }
      ]
    }
  ]
}
  • importer is the file that contains the unresolved import.
  • specifier is the raw import string.
  • matchedAliases shows package or config aliases that looked relevant.
  • candidateFiles shows resolver candidates and whether each exists or is inside project scope.

Explain Export Report

Use --explain-export <file>:<symbol> when an export result is surprising. In text mode, Codescythe prints a human-readable explanation. With JSON, the explanation is available under explainExport.

npx codescythe --explain-export src/constants.ts:oldFlag
npx codescythe --json --explain-export src/constants.ts:oldFlag
{
  "explainExport": {
    "exportingFile": "src/constants.ts",
    "symbol": "oldFlag",
    "status": "dead",
    "reason": "export is not used by reachable importers",
    "explanation": {
      "fileReachable": true,
      "importersConsidered": [],
      "importersSkipped": [
        {
          "importer": "src/constants.test.ts",
          "specifier": "./constants",
          "reason": "test file leaf"
        }
      ],
      "ignoredUnresolvedImportsThatMightHavePointedAtThisFile": []
    }
  }
}
status
Decision

Typeenum

Valuesalive | dead | fileUnused | fileNotFound | symbolNotExported

Alive exports are kept; dead exports can be removed if no safety guard blocks the edit.

reason
Short explanation

Typestring

ValuesGenerated from the graph decision.

Read this first, then inspect importer details when it disagrees with expectation.

fileReachable
Reachability check

Typeboolean

Valuestrue when the exporting file is reachable from configured entries.

If false, the export is usually secondary to an unused-file finding.

importersConsidered
Importers that count

TypeExportImportExplanation[]

ValuesEach item has importer, specifier, and reason.

Reasons include named import, namespace member access, re-export, dynamic import marks all exports, and export star marks all exports.

importersSkipped
Importers that do not count

TypeSkippedImporterExplanation[]

ValuesEach item has importer, specifier, and reason.

Common reasons are test file leaf or importer unreachable.

ignoredUnresolvedImportsThatMightHavePointedAtThisFile
Uncertainty from ignored imports

TypeIgnoredUnresolvedImportSample[]

ValuesSamples with specifier and importer.

If this is non-empty, review unresolvedImports.ignore before trusting an export edit.

Query Output

Query JSON includes the parsed selectors, matched source and target nodes, unresolved imports observed while building the graph, and either paths or a graph depending on the query kind.

{
  "kind": "somepath",
  "from": { "kind": "file", "path": "src/main.ts" },
  "to": { "kind": "export", "path": "src/module.ts", "symbol": "used" },
  "paths": [
    {
      "nodes": [
        { "id": "file:src/main.ts", "kind": "file", "path": "src/main.ts" },
        { "id": "export:src/module.ts:used", "kind": "export", "path": "src/module.ts", "symbol": "used" }
      ],
      "edges": [
        { "kind": "namedImport", "specifier": "./module", "imported": "used" }
      ]
    }
  ]
}

allpaths returns graph.nodes and graph.edges instead of paths. Diagram formats render that same data as Mermaid or SVG.

Review Workflow

  1. Start with doctor

    npx codescythe doctor --json --config codescythe.jsonc
  2. Fix config-risk warnings first

    Zero-match entries, broad project scopes, and source-alias unresolved ignores can all make the main cleanup report less trustworthy.

  3. Explain surprising exports

    npx codescythe --json --explain-export src/module.ts:legacyExport
  4. Only then run fix mode

    A clean doctor report and explain output that matches your expectations give fix mode a much narrower review surface.