Skip to content

feat(cli): add map command - #448

Merged
HugoRCD merged 5 commits into
mainfrom
feat/cli-map-command
Jul 26, 2026
Merged

feat(cli): add map command#448
HugoRCD merged 5 commits into
mainfrom
feat/cli-map-command

Conversation

@HugoRCD

@HugoRCD HugoRCD commented Jul 24, 2026

Copy link
Copy Markdown
Owner

📚 Description

evlog map gives an app a static observability score, Lighthouse-style. It detects the framework (Nuxt, Nitro, Next.js App Router, TanStack Start), scans every entry point, and scores wide-event coverage: useLogger(), request context, structured errors, audit trails on sensitive routes, and error handling.

  • Checks and suggestions are driven by a rule registry (src/lib/map/rules/) rather than scattered conditionals: one AST traversal, a shared fact layer, and framework knowledge kept in the adapters.
  • Requirement rules move the score; opportunity rules only suggest, based on what the project already adopts (error catalog, audit, AI SDK, Better Auth).
  • evlog map <route-or-file> inspects a single entry point, --all prints the check matrix, --json emits a versioned payload, --min-score gates CI.
  • A verdict you disagree with can be turned off with a comment — // evlog-map-disable-next-line audit -- reason — which reports the check as n/a with the reason attached instead of costing score.

The lockfile carries the two new dependencies, oxc-parser and tinyglobby. Its diff is wide because several packages here are pinned to latest nightlies, so any install re-resolves them; a from-scratch regeneration was tried and broke the Vercel builds, so this is the resolution that CI validated.

Split out of the original PR, which CodeRabbit could not review at 187 files. The documentation moved to #451 and the turbo task-ordering fix to #450; this PR is now the CLI code alone.

📝 Checklist

Summary by CodeRabbit

  • New Features
    • Added the evlog map command to scan Nuxt, Nitro, Next.js App Router, and TanStack Start entry points and produce a static observability score.
    • Supports detailed inspections, --all coverage matrices, evlog.map.json output with --no-write, and CI gating via --min-score.
    • Added suppress/disable directives (evlog-map-disable-*) with n/a reporting and continued rule evaluation.
  • Documentation
    • Updated CLI docs with the new command variants and revised --json output contract (schemaVersion: 2) for evlog map and evlog doctor.
  • Tests
    • Added comprehensive unit and end-to-end coverage for scanning, rendering, scoring, directives, and framework detection.

@vercel

vercel Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
evlog-docs Ready Ready Preview, Comment, Open in v0 Jul 26, 2026 11:47am
evlog-telemetry Ready Ready Preview, Comment Jul 26, 2026 11:47am
just-use-evlog Ready Ready Preview, Comment Jul 26, 2026 11:47am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds the evlog map CLI command with framework detection, route extraction for Nuxt, Nitro, Next.js App Router, and TanStack Start, AST-based observability rules, scoring, reports, suppression directives, JSON output, CI gating, and extensive tests and fixtures.

Changes

Map command and observability scanner

Layer / File(s) Summary
Contracts, parsing, and project facts
packages/cli/src/lib/map/types.ts, parse.ts, facts.ts, utils.ts, project-facts.ts
Defines scan contracts, parses source files, extracts AST facts, detects project features, and normalizes routes.
Framework detection and adapters
packages/cli/src/lib/map/detect.ts, adapters/*
Detects supported frameworks and extracts route, handler, page, middleware, cron, and server-action metadata.
Rules, sensitivity, exemptions, and suppressions
packages/cli/src/lib/map/rules/*, sensitivity.ts, exemptions.ts, directives.ts
Evaluates observability requirements and opportunities, classifies sensitivity, exempts infrastructure routes, and processes disable directives.
Scanning, scoring, serialization, and reports
packages/cli/src/lib/map/scan.ts, score.ts, write.ts, report.ts
Analyzes routes, computes scores and grades, writes deterministic JSON, and renders default, matrix, inspection, warning, and gate views.
CLI integration
packages/cli/src/commands/map.ts, commands/index.ts, lib/errors.ts, core/output.ts
Registers evlog map, validates framework and score options, handles errors, supports output styling, writes reports, and applies --min-score exit status.
Tests and fixtures
packages/cli/test/map/*
Covers command execution, adapters, rules, scoring, sensitivity, suppressions, rendering, serialization, and Nuxt, Next.js, and TanStack Start fixtures.
Documentation and configuration
packages/cli/README.md, .changeset/*, .gitignore, eslint.config.mjs, packages/cli/package.json
Documents the command and JSON contract, records the minor release, ignores generated reports, excludes fixtures from linting, and adds runtime dependencies.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

  • HugoRCD/evlog#431: Extends the CLI command registry and shared output foundation introduced there.

Suggested labels: dependencies, documentation

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 65.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed Clear conventional-commit title that accurately summarizes the main addition: the new map CLI command.
Description check ✅ Passed Mostly matches the template with a detailed description and checklist, but it omits the Linked issue section.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cli-map-command

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@pkg-pr-new

pkg-pr-new Bot commented Jul 24, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@evlog/cli@448
npm i https://pkg.pr.new/evlog@448
npm i https://pkg.pr.new/@evlog/nuxthub@448
npm i https://pkg.pr.new/@evlog/telemetry@448

commit: 81c67d1

@HugoRCD
HugoRCD force-pushed the feat/cli-map-command branch from 447d026 to 94b7ef5 Compare July 24, 2026 14:38
@vercel
vercel Bot temporarily deployed to Preview – evlog-telemetry July 24, 2026 14:49 Inactive
@vercel
vercel Bot temporarily deployed to Preview – just-use-evlog July 24, 2026 14:49 Inactive
@HugoRCD HugoRCD self-assigned this Jul 25, 2026
@HugoRCD
HugoRCD marked this pull request as ready for review July 25, 2026 21:55
Repository owner deleted a comment from cursor Bot Jul 25, 2026
@HugoRCD HugoRCD changed the title feat(cli): add map command feat(cli): add the map command Jul 26, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 31

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cli/src/commands/map.ts`:
- Around line 149-152: Update parseMinScoreArg to validate the entire
--min-score string as a valid numeric threshold rather than using parseInt’s
partial parsing. For empty or invalid values such as “abc” and “80oops”, raise
the established dedicated CLI error instead of returning undefined; preserve
undefined only when the option is genuinely absent.

In `@packages/cli/src/lib/map/adapters/next.ts`:
- Around line 15-28: Update resolveAppDir to detect route files as well as page
files when selecting between app and src/app, so API-only projects resolve the
correct directory. Update routeDirFromFile to strip the root-level route
filename and return the app directory path for app/route.ts (and equivalent
extensions), while preserving nested route directory handling.
- Around line 116-131: Update the server-action discovery loop around globSync
and parseFile to read each matched file’s raw source and skip it unless the
source contains the “use server” directive before parsing. Preserve the existing
hasDirective validation and export processing for files that pass the prefilter.

In `@packages/cli/src/lib/map/adapters/tanstack-start.ts`:
- Line 42: Update the API-route detection condition in the TanStack Start
adapter to avoid using basename(file).includes('api'), which over-matches
unrelated filenames; instead, validate an exact filename stem or path segment
while preserving the existing /api/ prefix check.
- Around line 65-81: Update detectServerHandlers to match handler property names
using their original literal casing instead of converting prop.key.name with
toUpperCase. Only recognize the existing uppercase GET, POST, PUT, PATCH, and
DELETE names, while preserving the function-expression checks and handler
location reporting.

In `@packages/cli/src/lib/map/exemptions.ts`:
- Around line 3-13: Add JSDoc comments for the exported RouteExemption type and
the isInfrastructureRoute and infrastructureLabel helpers in exemptions.ts.
Document each public API’s purpose, inputs, and return value consistently with
the existing getRouteExemption and isSkipped comments, without changing
behavior.

In `@packages/cli/src/lib/map/facts.ts`:
- Around line 244-250: Remove the detached JSDoc block above patternNames; keep
describeCallee documented by its existing nearby comment and leave patternNames’
own documentation unchanged.
- Around line 416-420: Update the VariableDeclarator handling in facts
collection to register all names from destructured binding patterns, not only
Identifier ids. Reuse the existing patternNames helper for declarator.id and add
each returned name to localDeclarations, preserving current behavior for simple
identifiers so resolvesToEvlog does not treat shadowed bindings as auto-imports.

In `@packages/cli/src/lib/map/parse.ts`:
- Around line 208-233: Update findHttpMethodExports to inspect
ExportNamedDeclaration.specifiers in addition to declaration exports, resolve
each exported name such as GET, POST, PUT, PATCH, DELETE, HEAD, or OPTIONS, and
record its source location and method so aliases like export { handler as GET }
produce route entries. Preserve the existing FunctionDeclaration and
VariableDeclaration handling.

In `@packages/cli/src/lib/map/project-facts.ts`:
- Around line 119-164: Update the project scan around globSync and readFileSync
to avoid blocking the main thread during whole-tree traversal: use the
asynchronous glob/file-reading APIs and propagate the required async behavior
through the surrounding map flow. Extend IGNORED to exclude .git, build, .turbo,
.svelte-kit, and fixture directories while preserving the existing source
filtering and fact aggregation.
- Around line 74-83: Update the SOURCE_GLOBS definition used by project-facts
scanning to include .mjs, .cjs, and .cts alongside the existing TypeScript and
JavaScript extensions, keeping the existing glob structure and IGNORED patterns
unchanged.

In `@packages/cli/src/lib/map/report.ts`:
- Around line 447-453: Update the “Already solid” list in the solid-route
reporting block to map routes through the existing displayName symbol instead of
route.path, matching the representation already used by the THEN groups while
preserving the current fitItems and formatting behavior.
- Around line 905-910: Update formatEntryPointNotFound to normalize query by
stripping the leading "./" using the same logic as findEntryPoint before
filtering nearby routes. Use the normalized value for both route.file and
route.path matching while preserving the existing suggestion limit.
- Around line 146-181: Move the JSDoc describing the documentation-link behavior
so it directly precedes createReportStyle, and keep the MIN_WIDTH/MAX_WIDTH
comment immediately above MIN_WIDTH. Ensure createReportStyle is documented by
that block without changing the implementation.

In `@packages/cli/src/lib/map/rules/ai-logging.ts`:
- Around line 44-55: Update the onEnd handler in create to select the earliest
AI SDK call by source line rather than relying on AI_CALLS.flatMap grouping
order. Reuse the source-ordered facts.calls collection, filter it to calls
matching AI_CALLS, and report the first matching call while preserving the
existing message and reporting behavior.

In `@packages/cli/src/lib/map/rules/audit.ts`:
- Around line 4-9: Rename isNamedSegment to reflect that it returns true for
unnamed route segments, then update every caller to use the new predicate name
while preserving the existing boolean logic and behavior.

In `@packages/cli/src/lib/map/rules/index.ts`:
- Around line 153-174: Move the getRouteExemption(target) lookup and its
exemption handling in runRuleSet above the !parsed || !facts early-return
branch. Ensure exempt routes continue returning n/a results with the exemption
reason, including when parsing fails, while non-exempt unparseable files retain
the existing requirement failures.

In `@packages/cli/src/lib/map/rules/types.ts`:
- Around line 50-52: Update the RuleListeners type so its listener map keys use
the discriminated Node['type'] union instead of string, while preserving the
existing listener callback signature and optional onEnd handler.

In `@packages/cli/src/lib/map/scan.ts`:
- Around line 37-49: The analyseRoute flow repeatedly parses the same route file
for each HTTP method. Add or reuse a path-keyed cache in the parseFile
implementation, or cache the computed file facts by path, so repeated calls for
the same file share one parsed result while preserving existing parsing,
warning, and route-analysis behavior.

In `@packages/cli/src/lib/map/score.ts`:
- Line 25: Add JSDoc comments to the exported functions scoreGlobal,
gradeFromScore, classifyRouteObservability, and topIssue, matching the existing
documentation style used by scoreRoute and routeCheckChips. Document each
function’s purpose and relevant inputs/outputs, explicitly noting scoreGlobal’s
weighting precedence where page weight 0.5 overrides high-sensitivity weight 2.
- Around line 55-58: Update the page branch in the route scoring logic around
pageErr so both an n/a status and an unchecked (undefined) result are treated as
having nothing to instrument rather than classified as dark. Preserve the
existing instrumented result for pass, and ensure only an explicitly failing
page-error-handling check remains dark.

In `@packages/cli/src/lib/map/sensitivity.ts`:
- Around line 76-88: Add JSDoc for the exported sensitivityBadge and
sensitivityLabel functions in packages/cli/src/lib/map/sensitivity.ts,
documenting their returned badge and label semantics; optionally derive
sensitivityBadge from sensitivityLabel to avoid duplicated reason-prefix checks.
Also add JSDoc for serializeMapFile in packages/cli/src/lib/map/write.ts,
stating that routes are sorted and no data is written to disk.
- Around line 19-24: Precompile the regex patterns for MONEY_TERMS and
AUTH_TERMS once at module load, rather than constructing RegExp instances inside
matchTerm. Update matchTerm to accept and test the compiled patterns, and change
the callers around the MONEY_TERMS and AUTH_TERMS usages to pass those
precompiled lists while preserving the existing matching results.

In `@packages/cli/src/lib/map/utils.ts`:
- Around line 24-26: Add JSDoc comments for the exported helpers stripExtension,
lineSnippet, and frameworkLabel in this module, documenting each function’s
purpose and relevant parameters or return value while leaving their
implementations unchanged.
- Around line 74-76: Update relativeFromRoot to use node:path normalization and
relative-path utilities so POSIX and Windows separators are handled consistently
and trailing root separators do not remove the first filename character. Ensure
the returned value is correctly relative to root, while preserving the original
file when it is outside the root.

In `@packages/cli/src/lib/map/write.ts`:
- Around line 5-10: Update sortedRoutes to replace both localeCompare calls with
a locale-independent deterministic string comparison for route paths and
methods, preserving path as the primary key and method as the tie-breaker so
serialized maps and snapshots have consistent ordering across machines.

In `@packages/cli/test/map.command.test.ts`:
- Around line 289-294: Update the schema/minScore test invocations around
map.run to use runCommand(map, { rawArgs: [...] }) instead of constructing a
citty context manually. Supply the relevant schema and minScore arguments
through rawArgs so citty performs parsing and produces a complete ParsedArgs
object, while preserving each test’s intended command behavior.

In `@packages/cli/test/map/fixtures/tanstack-basic/src/routes/api/admin.ts`:
- Line 1: Declare `@tanstack/react-router` as a dependency in the tanstack-basic
fixture’s package.json to match the import in createFileRoute and keep the
fixture self-describing.

In `@packages/cli/test/map/rules.test.ts`:
- Around line 99-106: Update the Case test fixture model to add an optional
dependencies field that defaults to pairable when omitted, then construct
ProjectFacts.dependencies from that field while keeping ProjectFacts.pairable
sourced from pairable. Preserve existing cases through the fallback while
allowing tests to define dependencies independently.

In `@packages/cli/test/map/scan.test.ts`:
- Around line 136-167: Refactor the checks suite to run scan(ctx(root, 'nuxt'))
once in a beforeAll and reuse the stored result across all four tests. Add
beforeAll to the vitest imports, and update each test to read routes from the
shared scan result while preserving the existing assertions.

In `@packages/cli/test/map/score.test.ts`:
- Around line 6-12: Update the scoreRoute tests to derive the failed-check
expectation from getRule('wide-event').weight rather than hard-coding 60, and
expand the grade assertions to cover exact boundary scores 90, 70, and 50.
Preserve the existing behavior checks while verifying threshold comparisons use
the intended inclusive boundaries.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3c171fc7-bfd5-442c-8bee-ee96721a1b2d

📥 Commits

Reviewing files that changed from the base of the PR and between 7ebca51 and 6c60eb9.

⛔ Files ignored due to path filters (2)
  • packages/cli/test/map/__snapshots__/scan.test.ts.snap is excluded by !**/*.snap
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (80)
  • .changeset/cli-docs-links.md
  • .changeset/cli-early-days-note.md
  • .changeset/map-disable-comments.md
  • .changeset/rebuild-map-command.md
  • .gitignore
  • eslint.config.mjs
  • packages/cli/README.md
  • packages/cli/package.json
  • packages/cli/src/commands/index.ts
  • packages/cli/src/commands/map.ts
  • packages/cli/src/core/output.ts
  • packages/cli/src/lib/errors.ts
  • packages/cli/src/lib/map/adapters/index.ts
  • packages/cli/src/lib/map/adapters/next.ts
  • packages/cli/src/lib/map/adapters/nuxt.ts
  • packages/cli/src/lib/map/adapters/tanstack-start.ts
  • packages/cli/src/lib/map/detect.ts
  • packages/cli/src/lib/map/directives.ts
  • packages/cli/src/lib/map/exemptions.ts
  • packages/cli/src/lib/map/facts.ts
  • packages/cli/src/lib/map/parse.ts
  • packages/cli/src/lib/map/project-facts.ts
  • packages/cli/src/lib/map/report.ts
  • packages/cli/src/lib/map/rules/ai-logging.ts
  • packages/cli/src/lib/map/rules/audit-coverage.ts
  • packages/cli/src/lib/map/rules/audit.ts
  • packages/cli/src/lib/map/rules/auth-identity.ts
  • packages/cli/src/lib/map/rules/context.ts
  • packages/cli/src/lib/map/rules/error-catalog.ts
  • packages/cli/src/lib/map/rules/error-handling.ts
  • packages/cli/src/lib/map/rules/index.ts
  • packages/cli/src/lib/map/rules/page-error-handling.ts
  • packages/cli/src/lib/map/rules/structured-errors.ts
  • packages/cli/src/lib/map/rules/types.ts
  • packages/cli/src/lib/map/rules/wide-event.ts
  • packages/cli/src/lib/map/scan.ts
  • packages/cli/src/lib/map/score.ts
  • packages/cli/src/lib/map/sensitivity.ts
  • packages/cli/src/lib/map/types.ts
  • packages/cli/src/lib/map/utils.ts
  • packages/cli/src/lib/map/write.ts
  • packages/cli/test/map.command.test.ts
  • packages/cli/test/map/detect.test.ts
  • packages/cli/test/map/directives.test.ts
  • packages/cli/test/map/display.test.ts
  • packages/cli/test/map/exemptions.test.ts
  • packages/cli/test/map/fixtures/.gitignore
  • packages/cli/test/map/fixtures/next-app-router/app/actions/orders.ts
  • packages/cli/test/map/fixtures/next-app-router/app/api/checkout/route.ts
  • packages/cli/test/map/fixtures/next-app-router/app/api/error/route.ts
  • packages/cli/test/map/fixtures/next-app-router/app/api/health/route.ts
  • packages/cli/test/map/fixtures/next-app-router/app/api/invoices/route.ts
  • packages/cli/test/map/fixtures/next-app-router/app/api/payments/route.ts
  • packages/cli/test/map/fixtures/next-app-router/app/page.tsx
  • packages/cli/test/map/fixtures/next-app-router/lib/evlog.ts
  • packages/cli/test/map/fixtures/next-app-router/middleware.ts
  • packages/cli/test/map/fixtures/next-app-router/package.json
  • packages/cli/test/map/fixtures/nuxt-basic/package.json
  • packages/cli/test/map/fixtures/nuxt-basic/pages/index.vue
  • packages/cli/test/map/fixtures/nuxt-basic/pages/orders/[id].vue
  • packages/cli/test/map/fixtures/nuxt-basic/server/api/broken-error.get.ts
  • packages/cli/test/map/fixtures/nuxt-basic/server/api/checkout.post.ts
  • packages/cli/test/map/fixtures/nuxt-basic/server/api/docs/[...slug].get.ts
  • packages/cli/test/map/fixtures/nuxt-basic/server/api/orders/[id].get.ts
  • packages/cli/test/map/fixtures/nuxt-basic/server/api/orders/[id].head.ts
  • packages/cli/test/map/fixtures/nuxt-basic/server/api/payments/stripe.post.ts
  • packages/cli/test/map/fixtures/nuxt-basic/server/api/plain-error.get.ts
  • packages/cli/test/map/fixtures/nuxt-basic/server/middleware/auth.ts
  • packages/cli/test/map/fixtures/nuxt-basic/server/routes/health.get.ts
  • packages/cli/test/map/fixtures/nuxt-basic/server/tasks/cleanup.ts
  • packages/cli/test/map/fixtures/nuxt-basic/server/utils/errors.ts
  • packages/cli/test/map/fixtures/tanstack-basic/package.json
  • packages/cli/test/map/fixtures/tanstack-basic/src/routes/api/admin.ts
  • packages/cli/test/map/fixtures/tanstack-basic/src/routes/api/checkout.ts
  • packages/cli/test/map/fixtures/tanstack-basic/src/routes/api/hello.ts
  • packages/cli/test/map/fixtures/tanstack-basic/src/routes/index.tsx
  • packages/cli/test/map/rules.test.ts
  • packages/cli/test/map/scan.test.ts
  • packages/cli/test/map/score.test.ts
  • packages/cli/test/map/sensitivity.test.ts

Comment thread packages/cli/src/commands/map.ts Outdated
Comment thread packages/cli/src/lib/map/adapters/next.ts
Comment thread packages/cli/src/lib/map/adapters/next.ts
Comment thread packages/cli/src/lib/map/adapters/tanstack-start.ts Outdated
Comment thread packages/cli/src/lib/map/adapters/tanstack-start.ts
Comment thread packages/cli/test/map.command.test.ts Outdated
Comment thread packages/cli/test/map/rules.test.ts
Comment thread packages/cli/test/map/scan.test.ts
Comment thread packages/cli/test/map/score.test.ts
@vercel
vercel Bot temporarily deployed to Preview – evlog-telemetry July 26, 2026 09:54 Inactive
@vercel
vercel Bot temporarily deployed to Preview – evlog-docs July 26, 2026 09:54 Inactive
@vercel
vercel Bot temporarily deployed to Preview – just-use-evlog July 26, 2026 09:54 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 18

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@eslint.config.mjs`:
- Around line 31-38: Make the repository test suite pass for the fixture-only
change by identifying the failing test task and addressing its specific failure.
Update the fixture handling near the eslint configuration’s
packages/cli/test/map/fixtures/** ignore only if the failure is caused by these
throwaway fixtures; otherwise correct the failing fixture or implementation
while preserving the map test expectations. Verify pnpm lint, pnpm typecheck,
and pnpm test all succeed.

In `@packages/cli/README.md`:
- Around line 87-94: Update the JSON output example in the CLI README to include
the emitted mapPath field, documenting it as the output path when writing is
enabled and null when invoked with --no-write.
- Around line 18-20: Update the “Early days” description for evlog map in the
CLI README to state that it writes evlog.map.json by default and only avoids
writing when --no-write is supplied; remove the inaccurate claim that it only
reads files while preserving the surrounding safety and maturity guidance.

In `@packages/cli/src/commands/map.ts`:
- Around line 183-222: Move the parseMinScoreArg call that initializes threshold
into the existing try block before runMap, alongside parseFrameworkArg, so
invalid --min-score values are validated before scanning or writing. Keep the
existing EvlogError handling applied to validation failures and reuse the
validated threshold for reporting and exit-status checks.

In `@packages/cli/src/lib/map/adapters/next.ts`:
- Around line 129-144: Update findServerActionExports and its use in the Next
adapter to include aliased exports such as export { createOrder } and named
default function declarations, including async functions, while preserving the
existing export function and exported const arrow/function detection. Ensure
each discovered action retains its correct exported name and source location for
route generation.

In `@packages/cli/src/lib/map/adapters/nuxt.ts`:
- Around line 223-225: Add JSDoc to the exported getNuxtOrNitroAdapter function,
documenting its purpose, framework parameter, and returned adapter; also add a
corresponding JSDoc comment to the exported nuxtAdapter to satisfy the public
API documentation guideline.
- Around line 161-217: Refactor extractRoutes to reuse the existing
fileToApiRoute and fileToMiddlewareRoute helpers instead of duplicating their
parsing and handler-location logic. Extend those helpers with a framework value
and prefix resolver as needed, then configure the Nitro adapter to use framework
"nitro", preserve its routes/api prefix rules, and retain the existing
middleware behavior.

In `@packages/cli/src/lib/map/exemptions.ts`:
- Around line 23-26: Update INFRA_FILE_PATTERNS and the matching logic in the
exemptions mapping flow to require an exact path segment or boundary-aware match
instead of plain substring containment. Ensure files such as
lib/evlog/ingestable.ts and routes/api/legacy-evlog/ingest-report.ts are not
classified as infrastructure, while the intended ingest endpoint paths continue
receiving skip: 'all'.

In `@packages/cli/src/lib/map/facts.ts`:
- Around line 309-324: Extend statementHandlesError to recursively inspect
nested statement bodies, including BlockStatement, conditional branches, switch
cases, and nested try/catch/finally blocks, while preserving the existing direct
throw, return, console, and handling-member checks. Return true when any
reachable nested statement handles the error so conditional catch patterns such
as logging one branch and rethrowing another are detected.

In `@packages/cli/src/lib/map/rules/ai-logging.ts`:
- Around line 26-29: Update the ai-logging rule’s when predicate to use a
project-wide evlog/ai import signal rather than the route-local
facts.evlogImports check. Preserve the existing project.pairable and AI_CALLS
conditions, and ensure handlers are not flagged when a reused project wrapper
imports or instantiates evlog/ai.

In `@packages/cli/src/lib/map/rules/page-error-handling.ts`:
- Around line 47-52: Update the error-handling rule around the handled check to
associate catches, catch calls, onError handlers, catchError handlers, and
destructured network errors with each individual network request fact. Remove
the file-wide suppression based on facts.catches, facts.callsTo, and
facts.destructuresNetworkError, and only mark a request handled when its own
error handler is linked to that request.

In `@packages/cli/src/lib/map/score.ts`:
- Around line 34-49: Update scoreGlobal to exclude routes classified as exempt
before calculating totalWeight and weightedSum. Use the existing exemption
indicator or classification logic from RouteEntry, preserve the current
weighting for non-exempt routes, and return 100 when no non-exempt routes
remain.

In `@packages/cli/src/lib/map/utils.ts`:
- Around line 13-28: Update extractMethodFromFilename and stripExtension to
recognize and remove .mjs and .cjs alongside the existing JavaScript and
TypeScript extensions, so filenames such as checkout.post.mjs yield the HTTP
method and extension-free route path. Keep the existing method normalization and
other extension handling unchanged.

In `@packages/cli/test/map/fixtures/next-app-router/app/api/checkout/route.ts`:
- Around line 3-4: Wrap the POST handlers in both
packages/cli/test/map/fixtures/next-app-router/app/api/checkout/route.ts (lines
3-4) and
packages/cli/test/map/fixtures/next-app-router/app/api/invoices/route.ts (lines
3-4) with the supported evlog withEvlog wrapper, and import it as needed. Ensure
each wrapped handler provides the request-scoped logger expected by useLogger
without treating Request as a ServerEvent.

In `@packages/cli/test/map/fixtures/next-app-router/app/api/payments/route.ts`:
- Line 4: Replace the credential-like literal passed to the Stripe constructor
in the route fixture with an environment-provided test value or a mocked client.
Ensure no API-key-shaped string remains committed in this fixture.

In
`@packages/cli/test/map/fixtures/nuxt-basic/server/api/payments/stripe.post.ts`:
- Line 4: Replace the credential-like literal passed to the Stripe constructor
in the fixture with an environment-provided test value or a mocked Stripe
client. Ensure no API-key-shaped string remains committed while preserving the
fixture’s test behavior.

In `@packages/cli/test/map/fixtures/nuxt-basic/server/api/plain-error.get.ts`:
- Around line 1-3: Add JSDoc comments for every exported fixture API: the
default handlers in
packages/cli/test/map/fixtures/nuxt-basic/server/api/plain-error.get.ts (lines
1-3), server/middleware/auth.ts (lines 1-3), server/routes/health.get.ts (lines
1-3), and server/tasks/cleanup.ts (lines 1-6); orderErrors in
server/utils/errors.ts (lines 3-10); and Route in
packages/cli/test/map/fixtures/tanstack-basic/src/routes/api/admin.ts (lines
3-15), checkout.ts (lines 4-19), and hello.ts (lines 3-11). Document each symbol
according to the repository’s public API JSDoc convention without changing
behavior.

In `@packages/cli/test/map/fixtures/tanstack-basic/src/routes/api/checkout.ts`:
- Line 8: Replace the no-argument useLogger() call in the generated checkout
route with the supported TanStack evlog integration and its event-free logger
API. Update the corresponding import or setup so the route no longer relies on
server-context event initialization.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 643aa619-1bbd-42dd-92f8-35912b417e18

📥 Commits

Reviewing files that changed from the base of the PR and between 6c60eb9 and d1cf264.

⛔ Files ignored due to path filters (2)
  • packages/cli/test/map/__snapshots__/scan.test.ts.snap is excluded by !**/*.snap
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (80)
  • .changeset/rebuild-map-command.md
  • .gitignore
  • eslint.config.mjs
  • packages/cli/README.md
  • packages/cli/package.json
  • packages/cli/src/commands/index.ts
  • packages/cli/src/commands/map.ts
  • packages/cli/src/core/output.ts
  • packages/cli/src/lib/errors.ts
  • packages/cli/src/lib/map/adapters/index.ts
  • packages/cli/src/lib/map/adapters/next.ts
  • packages/cli/src/lib/map/adapters/nuxt.ts
  • packages/cli/src/lib/map/adapters/tanstack-start.ts
  • packages/cli/src/lib/map/detect.ts
  • packages/cli/src/lib/map/directives.ts
  • packages/cli/src/lib/map/exemptions.ts
  • packages/cli/src/lib/map/facts.ts
  • packages/cli/src/lib/map/parse.ts
  • packages/cli/src/lib/map/project-facts.ts
  • packages/cli/src/lib/map/report.ts
  • packages/cli/src/lib/map/rules/ai-logging.ts
  • packages/cli/src/lib/map/rules/audit-coverage.ts
  • packages/cli/src/lib/map/rules/audit.ts
  • packages/cli/src/lib/map/rules/auth-identity.ts
  • packages/cli/src/lib/map/rules/context.ts
  • packages/cli/src/lib/map/rules/error-catalog.ts
  • packages/cli/src/lib/map/rules/error-handling.ts
  • packages/cli/src/lib/map/rules/index.ts
  • packages/cli/src/lib/map/rules/page-error-handling.ts
  • packages/cli/src/lib/map/rules/structured-errors.ts
  • packages/cli/src/lib/map/rules/types.ts
  • packages/cli/src/lib/map/rules/wide-event.ts
  • packages/cli/src/lib/map/scan.ts
  • packages/cli/src/lib/map/score.ts
  • packages/cli/src/lib/map/sensitivity.ts
  • packages/cli/src/lib/map/types.ts
  • packages/cli/src/lib/map/utils.ts
  • packages/cli/src/lib/map/write.ts
  • packages/cli/test/map.command.test.ts
  • packages/cli/test/map/adapters.test.ts
  • packages/cli/test/map/detect.test.ts
  • packages/cli/test/map/directives.test.ts
  • packages/cli/test/map/display.test.ts
  • packages/cli/test/map/exemptions.test.ts
  • packages/cli/test/map/fixtures/.gitignore
  • packages/cli/test/map/fixtures/next-app-router/app/actions/orders.ts
  • packages/cli/test/map/fixtures/next-app-router/app/api/checkout/route.ts
  • packages/cli/test/map/fixtures/next-app-router/app/api/error/route.ts
  • packages/cli/test/map/fixtures/next-app-router/app/api/health/route.ts
  • packages/cli/test/map/fixtures/next-app-router/app/api/invoices/route.ts
  • packages/cli/test/map/fixtures/next-app-router/app/api/payments/route.ts
  • packages/cli/test/map/fixtures/next-app-router/app/page.tsx
  • packages/cli/test/map/fixtures/next-app-router/lib/evlog.ts
  • packages/cli/test/map/fixtures/next-app-router/middleware.ts
  • packages/cli/test/map/fixtures/next-app-router/package.json
  • packages/cli/test/map/fixtures/nuxt-basic/package.json
  • packages/cli/test/map/fixtures/nuxt-basic/pages/index.vue
  • packages/cli/test/map/fixtures/nuxt-basic/pages/orders/[id].vue
  • packages/cli/test/map/fixtures/nuxt-basic/server/api/broken-error.get.ts
  • packages/cli/test/map/fixtures/nuxt-basic/server/api/checkout.post.ts
  • packages/cli/test/map/fixtures/nuxt-basic/server/api/docs/[...slug].get.ts
  • packages/cli/test/map/fixtures/nuxt-basic/server/api/orders/[id].get.ts
  • packages/cli/test/map/fixtures/nuxt-basic/server/api/orders/[id].head.ts
  • packages/cli/test/map/fixtures/nuxt-basic/server/api/payments/stripe.post.ts
  • packages/cli/test/map/fixtures/nuxt-basic/server/api/plain-error.get.ts
  • packages/cli/test/map/fixtures/nuxt-basic/server/middleware/auth.ts
  • packages/cli/test/map/fixtures/nuxt-basic/server/routes/health.get.ts
  • packages/cli/test/map/fixtures/nuxt-basic/server/tasks/cleanup.ts
  • packages/cli/test/map/fixtures/nuxt-basic/server/utils/errors.ts
  • packages/cli/test/map/fixtures/tanstack-basic/package.json
  • packages/cli/test/map/fixtures/tanstack-basic/src/routes/api/admin.ts
  • packages/cli/test/map/fixtures/tanstack-basic/src/routes/api/checkout.ts
  • packages/cli/test/map/fixtures/tanstack-basic/src/routes/api/hello.ts
  • packages/cli/test/map/fixtures/tanstack-basic/src/routes/index.tsx
  • packages/cli/test/map/project-facts.test.ts
  • packages/cli/test/map/rules.test.ts
  • packages/cli/test/map/scan.test.ts
  • packages/cli/test/map/score.test.ts
  • packages/cli/test/map/sensitivity.test.ts
  • packages/cli/test/map/write.test.ts

Comment thread eslint.config.mjs
Comment thread packages/cli/README.md Outdated
Comment thread packages/cli/README.md
Comment thread packages/cli/src/commands/map.ts
Comment thread packages/cli/src/lib/map/adapters/next.ts
Comment thread packages/cli/test/map/fixtures/next-app-router/app/api/payments/route.ts Outdated
Comment thread packages/cli/test/map/fixtures/nuxt-basic/server/api/payments/stripe.post.ts Outdated
Comment thread packages/cli/test/map/fixtures/tanstack-basic/src/routes/api/checkout.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cli/test/map/fixtures/tanstack-basic/src/routes/api/checkout.ts`:
- Line 6: Add concise JSDoc documenting the exported Route API in
packages/cli/test/map/fixtures/tanstack-basic/src/routes/api/checkout.ts at line
6, and document the exported POST handler in
packages/cli/test/map/fixtures/next-app-router/app/api/payments/route.ts at line
4, following the project’s public API documentation guidelines.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a109cddf-1b67-4a31-9d0d-cc9151615f47

📥 Commits

Reviewing files that changed from the base of the PR and between d1cf264 and 81c67d1.

⛔ Files ignored due to path filters (1)
  • packages/cli/test/map/__snapshots__/scan.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (20)
  • .changeset/rebuild-map-command.md
  • packages/cli/README.md
  • packages/cli/src/commands/map.ts
  • packages/cli/src/lib/map/adapters/next.ts
  • packages/cli/src/lib/map/adapters/nuxt.ts
  • packages/cli/src/lib/map/exemptions.ts
  • packages/cli/src/lib/map/facts.ts
  • packages/cli/src/lib/map/rules/ai-logging.ts
  • packages/cli/src/lib/map/rules/page-error-handling.ts
  • packages/cli/src/lib/map/score.ts
  • packages/cli/src/lib/map/utils.ts
  • packages/cli/test/map.command.test.ts
  • packages/cli/test/map/adapters.test.ts
  • packages/cli/test/map/exemptions.test.ts
  • packages/cli/test/map/fixtures/next-app-router/app/api/checkout/route.ts
  • packages/cli/test/map/fixtures/next-app-router/app/api/payments/route.ts
  • packages/cli/test/map/fixtures/nuxt-basic/server/api/payments/stripe.post.ts
  • packages/cli/test/map/fixtures/tanstack-basic/src/routes/api/checkout.ts
  • packages/cli/test/map/rules.test.ts
  • packages/cli/test/map/score.test.ts

@HugoRCD HugoRCD changed the title feat(cli): add the map command feat(cli): add map command Jul 26, 2026
@HugoRCD
HugoRCD merged commit cb5c1df into main Jul 26, 2026
21 checks passed
@HugoRCD
HugoRCD deleted the feat/cli-map-command branch July 26, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant