Skip to content

Conversation

@luxass
Copy link
Member

@luxass luxass commented Jan 5, 2026

🔗 Linked issue

📚 Description

This PR changes the ucd headers to be more standard. It also adds new headers, which will be used in the future, when we rewrite the api.

This helps close the mega pr of #420

Summary by CodeRabbit

  • New Features
    • API responses now expose expanded stat headers: type, size, total children, file children, and directory children to provide richer file/directory metadata.
  • Chores
    • CLI and tools updated to use the new stat header naming so metadata commands reflect the expanded headers consistently.

✏️ Tip: You can customize this high-level summary in your review settings.

luxass added 2 commits January 5, 2026 06:58
Updated the header constant to better reflect its purpose and ensure consistency across the codebase. Adjusted all relevant imports and usages in the API routes and tests.
Copilot AI review requested due to automatic review settings January 5, 2026 06:00
@changeset-bot
Copy link

changeset-bot bot commented Jan 5, 2026

⚠️ No Changeset found

Latest commit: c32b187

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added apps: api Changes related to the API. pkg: env Changes related to the Env package. labels Jan 5, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 5, 2026

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Renamed public header constant UCD_FILE_STAT_TYPE_HEADERUCD_STAT_TYPE_HEADER, added four new stat-related header constants, and updated imports/usages across API routes, CLI, and tests. No control-flow or API semantics beyond header name/export changes.

Changes

Cohort / File(s) Summary
Env package (constants & exports)
packages/env/src/constants.ts, packages/env/src/index.ts
Removed UCD_FILE_STAT_TYPE_HEADER; added/exported UCD_STAT_TYPE_HEADER, UCD_STAT_SIZE_HEADER, UCD_STAT_CHILDREN_HEADER, UCD_STAT_CHILDREN_FILES_HEADER, UCD_STAT_CHILDREN_DIRS_HEADER. Updated docs/example usages.
API route
apps/api/src/routes/v1_files/$wildcard.ts
Switched imports and all GET/HEAD response header additions from UCD_FILE_STAT_TYPE_HEADER to UCD_STAT_TYPE_HEADER.
CLI command
packages/cli/src/cmd/files/info.ts
Updated import and header reads to use UCD_STAT_TYPE_HEADER when building file/directory metadata.
Tests (API & CLI)
apps/api/test/routes/v1_files/$wildcard.test.ts, packages/cli/test/cmd/files/info.test.ts, apps/api/test/...*
Updated test imports, mocked responses, and assertions to reference UCD_STAT_TYPE_HEADER (replacing UCD_FILE_STAT_TYPE_HEADER).

(*Tests grouped where path prefixes match; see repo for exact test file list.)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

pkg: cli

Poem

🐰 I hopped through headers, small and bright,
Old name folded, new ones in sight,
Five little flags line up and sing,
Metadata twinkles on each wing,
A tiny rename—happy spring!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: renaming custom UCD header constants from the old naming convention to a standardized format.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fc681fc and c32b187.

📒 Files selected for processing (2)
  • packages/cli/src/cmd/files/info.ts
  • packages/cli/test/cmd/files/info.test.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{test,spec}.?(c|m)[jt]s?(x)

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{test,spec}.?(c|m)[jt]s?(x): Import test utilities from #test-utils/* path aliases instead of @ucdjs/test-utils in test files to avoid build step requirements and prevent cyclic dependencies
Use testdir() from vitest-testdirs to create temporary test directories in filesystem tests
Use mockStoreApi() utility from #test-utils/mock-store for MSW-based mocking of the UCD API in test files

Files:

  • packages/cli/test/cmd/files/info.test.ts
🧠 Learnings (7)
📚 Learning: 2025-12-27T11:08:54.630Z
Learnt from: CR
Repo: ucdjs/ucd PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T11:08:54.630Z
Learning: Applies to **/*.{test,spec}.?(c|m)[jt]s?(x) : Import test utilities from #test-utils/* path aliases instead of ucdjs/test-utils in test files to avoid build step requirements and prevent cyclic dependencies

Applied to files:

  • packages/cli/test/cmd/files/info.test.ts
📚 Learning: 2025-06-09T05:10:32.105Z
Learnt from: luxass
Repo: ucdjs/ucd PR: 45
File: packages/ucd-store/src/download.ts:24-24
Timestamp: 2025-06-09T05:10:32.105Z
Learning: In the ucd-store package refactor, picomatch was moved from direct usage in download.ts to internal usage within the createPathFilter function in filter.ts. The pattern format is still picomatch-compatible, so JSDoc comments referencing picomatch pattern format remain correct.

Applied to files:

  • packages/cli/test/cmd/files/info.test.ts
  • packages/cli/src/cmd/files/info.ts
📚 Learning: 2025-10-14T07:15:35.199Z
Learnt from: luxass
Repo: ucdjs/ucd PR: 326
File: packages/shared/src/ucd-config.ts:34-58
Timestamp: 2025-10-14T07:15:35.199Z
Learning: In packages/shared/src/ucd-config.ts, the `getDefaultUCDEndpointConfig` function uses a build-time define `__UCD_ENDPOINT_DEFAULT_CONFIG__` that is replaced at build time by the bundler. The `??` operator is evaluated at build time, so the final code contains no runtime branching. Therefore, runtime unit tests for this function are not valuable—the build process itself handles the injection and fallback logic.

Applied to files:

  • packages/cli/test/cmd/files/info.test.ts
📚 Learning: 2025-12-27T11:08:54.630Z
Learnt from: CR
Repo: ucdjs/ucd PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T11:08:54.630Z
Learning: Applies to **/*.{test,spec}.?(c|m)[jt]s?(x) : Use mockStoreApi() utility from #test-utils/mock-store for MSW-based mocking of the UCD API in test files

Applied to files:

  • packages/cli/test/cmd/files/info.test.ts
📚 Learning: 2025-08-23T05:20:36.940Z
Learnt from: luxass
Repo: ucdjs/ucd PR: 209
File: packages/ucd-store/test/clean.test.ts:9-9
Timestamp: 2025-08-23T05:20:36.940Z
Learning: In the ucdjs/ucd codebase using modern Vitest, the assert export from "vitest" works as a callable function assert(condition, message) and provides TypeScript type narrowing, making it the preferred choice over expect() for runtime assertions that need compile-time type safety. The existing usage pattern assert(condition, message) throughout the test suite is working correctly.

Applied to files:

  • packages/cli/test/cmd/files/info.test.ts
📚 Learning: 2025-08-23T05:20:36.940Z
Learnt from: luxass
Repo: ucdjs/ucd PR: 209
File: packages/ucd-store/test/clean.test.ts:9-9
Timestamp: 2025-08-23T05:20:36.940Z
Learning: In the ucdjs/ucd codebase, Vitest's assert import works as a callable function assert(condition, message) and provides TypeScript type narrowing, making it the preferred choice over expect() for runtime assertions that also need compile-time type safety.

Applied to files:

  • packages/cli/test/cmd/files/info.test.ts
📚 Learning: 2025-08-23T05:16:26.866Z
Learnt from: luxass
Repo: ucdjs/ucd PR: 209
File: packages/ucd-store/test/clean.test.ts:9-9
Timestamp: 2025-08-23T05:16:26.866Z
Learning: In the ucdjs/ucd codebase, the team prefers using `assert(condition, message)` over `expect(condition).toBeTruthy()` because assert provides TypeScript type narrowing while expect doesn't. This is important for maintaining type safety after runtime validation checks.

Applied to files:

  • packages/cli/test/cmd/files/info.test.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: lint
  • GitHub Check: test (windows-latest)
  • GitHub Check: test (macos-latest)
🔇 Additional comments (4)
packages/cli/test/cmd/files/info.test.ts (2)

4-4: LGTM: Import updated to new header constant.

The import correctly uses the renamed constant UCD_STAT_TYPE_HEADER from @ucdjs/env, aligning with the refactoring across the codebase.


35-35: LGTM: All mock responses updated consistently.

All four test cases correctly use the new UCD_STAT_TYPE_HEADER constant in mock HTTP response headers. The changes are consistent with the implementation update and maintain test coverage for both file and directory metadata scenarios.

Also applies to: 59-59, 81-81, 126-126

packages/cli/src/cmd/files/info.ts (2)

4-4: LGTM: Import updated to new header constant.

The import correctly uses the renamed constant UCD_STAT_TYPE_HEADER from @ucdjs/env, matching the test file and API route updates.


98-98: LGTM: Header reading updated correctly.

The header retrieval logic now uses UCD_STAT_TYPE_HEADER, maintaining the same type assertion and fallback behavior while aligning with the renamed constant used throughout the codebase.


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 and usage tips.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

🌏 Preview Deployments

Note

No deployable apps affected by changes in this PR.

Built from commit: c32b187098b835f96a0f32a9edd6ff0deef32b4e


🤖 This comment will be updated automatically when you push new commits to this PR.

@codecov
Copy link

codecov bot commented Jan 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors custom UCD headers to follow a more standard naming convention, changing from UCD-File-Stat-Type to the X-UCD-Stat-* pattern. It also introduces four new header constants that will be used in future API rewrites.

  • Renames UCD_FILE_STAT_TYPE_HEADER to UCD_STAT_TYPE_HEADER with value X-UCD-Stat-Type
  • Adds four new header constants: UCD_STAT_SIZE_HEADER, UCD_STAT_CHILDREN_HEADER, UCD_STAT_CHILDREN_FILES_HEADER, and UCD_STAT_CHILDREN_DIRS_HEADER
  • Updates all references to the renamed header across the API implementation and tests

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
packages/env/src/constants.ts Renames header constant and adds four new header constants with standardized X-UCD-Stat-* naming
packages/env/src/index.ts Exports all five header constants (one renamed, four new)
apps/api/src/routes/v1_files/$wildcard.ts Updates import and all usage references from old header name to new UCD_STAT_TYPE_HEADER
apps/api/test/routes/v1_files/$wildcard.test.ts Updates test to use new header constant name

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/api/src/routes/v1_files/$wildcard.ts (1)

126-133: Run pnpm build:openapi to regenerate the OpenAPI specification.

The OpenAPI route definitions correctly use the UCD_STAT_TYPE_HEADER constant in the header schemas for both GET and HEAD routes. Since these are changes to API routes in this file, regenerate the OpenAPI spec per the build process.

🧹 Nitpick comments (1)
packages/env/src/constants.ts (1)

1-14: Update JSDoc to reflect multiple header constants.

The JSDoc comment refers to a singular "HTTP header name" and "this constant," but the file now exports five distinct header constants. Consider either:

  1. Converting this to a general module-level comment about UCD stat headers, or
  2. Moving individual JSDoc comments to each constant definition
🔎 Suggested JSDoc improvements

Option 1: Module-level documentation

 /**
- * HTTP header name for specifying the type of UCD statistics.
+ * HTTP header names for UCD statistics.
  *
- * This constant defines the header key used to indicate the type of
- * statistics being transmitted or requested in UCD-related HTTP communications.
+ * These constants define the header keys used for UCD statistics metadata
+ * in HTTP responses, including resource type, size, and directory child counts.
  *
  * @example
  * ```typescript
  * import { UCD_STAT_TYPE_HEADER, UCD_STAT_SIZE_HEADER } from "@ucdjs/env";
  *
  * headers[UCD_STAT_TYPE_HEADER] = "file";
  * headers[UCD_STAT_SIZE_HEADER] = "1024";
  * ```
  */

Option 2: Individual constant documentation

-/**
- * HTTP header name for specifying the type of UCD statistics.
- *
- * This constant defines the header key used to indicate the type of
- * statistics being transmitted or requested in UCD-related HTTP communications.
- *
- * @example
- * ```typescript
- * import { UCD_STAT_TYPE_HEADER, UCD_STAT_SIZE_HEADER } from "@ucdjs/env";
- *
- * headers[UCD_STAT_TYPE_HEADER] = "file";
- * headers[UCD_STAT_SIZE_HEADER] = "1024";
- * ```
- */
-
+/** Header indicating whether the resource is a "file" or "directory". */
 export const UCD_STAT_TYPE_HEADER = "X-UCD-Stat-Type";
+/** Header indicating the size of the resource in bytes. */
 export const UCD_STAT_SIZE_HEADER = "X-UCD-Stat-Size";
+/** Header indicating the total number of children in a directory. */
 export const UCD_STAT_CHILDREN_HEADER = "X-UCD-Stat-Children";
+/** Header indicating the number of file children in a directory. */
 export const UCD_STAT_CHILDREN_FILES_HEADER = "X-UCD-Stat-Children-Files";
+/** Header indicating the number of directory children in a directory. */
 export const UCD_STAT_CHILDREN_DIRS_HEADER = "X-UCD-Stat-Children-Dirs";
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b06a7dd and fc681fc.

📒 Files selected for processing (4)
  • apps/api/src/routes/v1_files/$wildcard.ts
  • apps/api/test/routes/v1_files/$wildcard.test.ts
  • packages/env/src/constants.ts
  • packages/env/src/index.ts
🧰 Additional context used
📓 Path-based instructions (5)
apps/api/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Regenerate OpenAPI spec by running 'pnpm build:openapi' after changing API routes or Zod schemas

Files:

  • apps/api/src/routes/v1_files/$wildcard.ts
apps/api/src/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

apps/api/src/**/*.ts: Build API (apps/api) using Hono web framework with OpenAPI plugin (@hono/zod-openapi) and organize routes by version and type
Use Zod schemas for defining API route schemas and request/response types in the API application

Files:

  • apps/api/src/routes/v1_files/$wildcard.ts
apps/api/src/routes/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

Document API endpoints with OpenAPI annotations using @hono/zod-openapi decorators

Files:

  • apps/api/src/routes/v1_files/$wildcard.ts
**/*.{test,spec}.?(c|m)[jt]s?(x)

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{test,spec}.?(c|m)[jt]s?(x): Import test utilities from #test-utils/* path aliases instead of @ucdjs/test-utils in test files to avoid build step requirements and prevent cyclic dependencies
Use testdir() from vitest-testdirs to create temporary test directories in filesystem tests
Use mockStoreApi() utility from #test-utils/mock-store for MSW-based mocking of the UCD API in test files

Files:

  • apps/api/test/routes/v1_files/$wildcard.test.ts
apps/api/test/**/*.{test,spec}.?(c|m)[jt]s?(x)

📄 CodeRabbit inference engine (AGENTS.md)

Place API app tests in apps/api/test/routes/** for endpoint tests and apps/api/test/unit/** for unit tests with mocks

Files:

  • apps/api/test/routes/v1_files/$wildcard.test.ts
🧠 Learnings (10)
📚 Learning: 2025-07-20T05:37:40.565Z
Learnt from: luxass
Repo: ucdjs/ucd PR: 131
File: tooling/eslint-plugin/package.json:0-0
Timestamp: 2025-07-20T05:37:40.565Z
Learning: In the ucdjs/ucd project, internal tooling packages (private packages in the tooling/ directory) export TypeScript files directly without requiring a build step, unlike published packages which use tsdown to build and export from ./dist/. Examples include ucdjs/tsdown-config and ucdjs/eslint-plugin.

Applied to files:

  • packages/env/src/index.ts
📚 Learning: 2025-06-09T05:10:32.105Z
Learnt from: luxass
Repo: ucdjs/ucd PR: 45
File: packages/ucd-store/src/download.ts:24-24
Timestamp: 2025-06-09T05:10:32.105Z
Learning: In the ucd-store package refactor, picomatch was moved from direct usage in download.ts to internal usage within the createPathFilter function in filter.ts. The pattern format is still picomatch-compatible, so JSDoc comments referencing picomatch pattern format remain correct.

Applied to files:

  • apps/api/src/routes/v1_files/$wildcard.ts
  • apps/api/test/routes/v1_files/$wildcard.test.ts
📚 Learning: 2025-12-27T11:08:54.630Z
Learnt from: CR
Repo: ucdjs/ucd PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T11:08:54.630Z
Learning: Applies to apps/api/src/routes/**/*.ts : Document API endpoints with OpenAPI annotations using hono/zod-openapi decorators

Applied to files:

  • apps/api/src/routes/v1_files/$wildcard.ts
📚 Learning: 2025-12-27T11:08:54.630Z
Learnt from: CR
Repo: ucdjs/ucd PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T11:08:54.630Z
Learning: Applies to apps/api/src/**/*.ts : Use Zod schemas for defining API route schemas and request/response types in the API application

Applied to files:

  • apps/api/src/routes/v1_files/$wildcard.ts
📚 Learning: 2025-12-27T11:08:54.630Z
Learnt from: CR
Repo: ucdjs/ucd PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T11:08:54.630Z
Learning: Applies to apps/api/src/**/*.ts : Build API (apps/api) using Hono web framework with OpenAPI plugin (hono/zod-openapi) and organize routes by version and type

Applied to files:

  • apps/api/src/routes/v1_files/$wildcard.ts
📚 Learning: 2025-12-27T11:08:54.630Z
Learnt from: CR
Repo: ucdjs/ucd PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T11:08:54.630Z
Learning: Applies to apps/api/src/**/*.{ts,tsx} : Regenerate OpenAPI spec by running 'pnpm build:openapi' after changing API routes or Zod schemas

Applied to files:

  • apps/api/src/routes/v1_files/$wildcard.ts
📚 Learning: 2025-12-27T11:08:54.630Z
Learnt from: CR
Repo: ucdjs/ucd PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T11:08:54.630Z
Learning: Applies to **/*.{test,spec}.?(c|m)[jt]s?(x) : Import test utilities from #test-utils/* path aliases instead of ucdjs/test-utils in test files to avoid build step requirements and prevent cyclic dependencies

Applied to files:

  • apps/api/test/routes/v1_files/$wildcard.test.ts
📚 Learning: 2025-10-14T07:15:35.199Z
Learnt from: luxass
Repo: ucdjs/ucd PR: 326
File: packages/shared/src/ucd-config.ts:34-58
Timestamp: 2025-10-14T07:15:35.199Z
Learning: In packages/shared/src/ucd-config.ts, the `getDefaultUCDEndpointConfig` function uses a build-time define `__UCD_ENDPOINT_DEFAULT_CONFIG__` that is replaced at build time by the bundler. The `??` operator is evaluated at build time, so the final code contains no runtime branching. Therefore, runtime unit tests for this function are not valuable—the build process itself handles the injection and fallback logic.

Applied to files:

  • apps/api/test/routes/v1_files/$wildcard.test.ts
📚 Learning: 2025-12-27T11:08:54.630Z
Learnt from: CR
Repo: ucdjs/ucd PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-27T11:08:54.630Z
Learning: Applies to **/*.{test,spec}.?(c|m)[jt]s?(x) : Use mockStoreApi() utility from #test-utils/mock-store for MSW-based mocking of the UCD API in test files

Applied to files:

  • apps/api/test/routes/v1_files/$wildcard.test.ts
📚 Learning: 2025-08-23T05:20:36.940Z
Learnt from: luxass
Repo: ucdjs/ucd PR: 209
File: packages/ucd-store/test/clean.test.ts:9-9
Timestamp: 2025-08-23T05:20:36.940Z
Learning: In the ucdjs/ucd codebase using modern Vitest, the assert export from "vitest" works as a callable function assert(condition, message) and provides TypeScript type narrowing, making it the preferred choice over expect() for runtime assertions that need compile-time type safety. The existing usage pattern assert(condition, message) throughout the test suite is working correctly.

Applied to files:

  • apps/api/test/routes/v1_files/$wildcard.test.ts
🧬 Code graph analysis (3)
apps/api/src/routes/v1_files/$wildcard.ts (2)
packages/env/src/constants.ts (1)
  • UCD_STAT_TYPE_HEADER (16-16)
packages/env/src/index.ts (1)
  • UCD_STAT_TYPE_HEADER (6-6)
packages/env/src/constants.ts (1)
packages/env/src/index.ts (5)
  • UCD_STAT_TYPE_HEADER (6-6)
  • UCD_STAT_SIZE_HEADER (5-5)
  • UCD_STAT_CHILDREN_HEADER (4-4)
  • UCD_STAT_CHILDREN_FILES_HEADER (3-3)
  • UCD_STAT_CHILDREN_DIRS_HEADER (2-2)
apps/api/test/routes/v1_files/$wildcard.test.ts (2)
packages/env/src/constants.ts (1)
  • UCD_STAT_TYPE_HEADER (16-16)
packages/env/src/index.ts (1)
  • UCD_STAT_TYPE_HEADER (6-6)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: typecheck
  • GitHub Check: lint
  • GitHub Check: Agent
  • GitHub Check: Greptile Review
  • GitHub Check: test (windows-latest)
  • GitHub Check: test (macos-latest)
🔇 Additional comments (6)
apps/api/test/routes/v1_files/$wildcard.test.ts (2)

2-2: LGTM! Import updated correctly.

The import has been properly updated to use the renamed constant UCD_STAT_TYPE_HEADER.


478-478: LGTM! Header usage updated correctly.

The test correctly uses the renamed header constant to verify the response header value.

apps/api/src/routes/v1_files/$wildcard.ts (2)

6-6: LGTM! Import updated correctly.

The import statement has been properly updated to use the renamed constant.


347-347: LGTM! Runtime header usage updated correctly.

The response headers are correctly set using the renamed constant, with values matching the OpenAPI schema definitions.

Also applies to: 362-362

packages/env/src/index.ts (1)

1-7: LGTM! Public exports updated correctly.

The module now correctly exports the five new header constants and removes the deprecated UCD_FILE_STAT_TYPE_HEADER. The new headers are well-prepared for future API usage as mentioned in the PR objectives.

packages/env/src/constants.ts (1)

16-20: LGTM! Header constants defined correctly.

The five new header constants follow a consistent naming pattern and HTTP custom header conventions. The constant names clearly describe their purpose, and the X-UCD-Stat-* header names provide good semantic meaning.

@greptile-apps
Copy link

greptile-apps bot commented Jan 5, 2026

Greptile Summary

This PR renames custom UCD headers to follow standard X- prefix convention and adds 4 new statistics headers for future API enhancements.

Key Changes

  • Renamed UCD-File-Stat-TypeX-UCD-Stat-Type (constant: UCD_FILE_STAT_TYPE_HEADERUCD_STAT_TYPE_HEADER)
  • Added 4 new headers: X-UCD-Stat-Size, X-UCD-Stat-Children, X-UCD-Stat-Children-Files, X-UCD-Stat-Children-Dirs
  • Updated API routes and tests to use renamed constant

Critical Issues Found

The refactor is incomplete - several files still reference the old constant name:

  • packages/cli/src/cmd/files/info.ts imports UCD_FILE_STAT_TYPE_HEADER (doesn't exist after rename)
  • packages/cli/test/cmd/files/info.test.ts uses old constant throughout tests
  • apps/web/src/apis/files.ts hardcodes "UCD-File-Stat-Type" instead of importing from @ucdjs/env

These will cause runtime failures when the CLI tries to read file metadata or when the web app fetches files.

Confidence Score: 1/5

  • This PR will break the CLI and web app due to incomplete refactoring
  • The refactor only updated the API package but missed critical consumers (CLI and web app) that depend on the renamed constant. The CLI will fail at import time with module resolution errors, and the web app will fail at runtime when checking the wrong header name. These are breaking changes that will cause immediate failures in production.
  • Pay close attention to packages/cli/src/cmd/files/info.ts, packages/cli/test/cmd/files/info.test.ts, and apps/web/src/apis/files.ts - all need updates to use the renamed constant

Important Files Changed

Filename Overview
packages/env/src/constants.ts Renamed header from UCD-File-Stat-Type to X-UCD-Stat-Type and added 4 new stat headers following X- prefix convention
packages/env/src/index.ts Updated exports to include all 5 new header constants with renamed UCD_STAT_TYPE_HEADER
apps/api/src/routes/v1_files/$wildcard.ts Updated all references from UCD_FILE_STAT_TYPE_HEADER to UCD_STAT_TYPE_HEADER consistently across route definitions and handlers
apps/api/test/routes/v1_files/$wildcard.test.ts Updated test to import and use renamed UCD_STAT_TYPE_HEADER constant

Sequence Diagram

sequenceDiagram
    participant Client as Client/CLI
    participant API as API (/api/v1/files)
    participant Env as @ucdjs/env
    participant Unicode as Unicode.org
    
    Note over Env: Constants defined:<br/>X-UCD-Stat-Type (renamed)<br/>X-UCD-Stat-Size (new)<br/>X-UCD-Stat-Children (new)<br/>X-UCD-Stat-Children-Files (new)<br/>X-UCD-Stat-Children-Dirs (new)
    
    Client->>API: GET /api/v1/files/{path}
    activate API
    
    API->>Env: Import UCD_STAT_TYPE_HEADER
    Env-->>API: "X-UCD-Stat-Type"
    
    API->>Unicode: Fetch file/directory
    activate Unicode
    Unicode-->>API: File content or directory listing
    deactivate Unicode
    
    API->>API: Set response headers
    Note over API: headers[UCD_STAT_TYPE_HEADER]<br/>= "file" or "directory"
    
    API-->>Client: Response with X-UCD-Stat-Type header
    deactivate API
    
    Client->>Client: Read X-UCD-Stat-Type header
    Note over Client: Determines if response is<br/>file content or directory listing
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (9)

  1. packages/cli/src/cmd/files/info.ts, line 4 (link)

    syntax: breaking change: UCD_FILE_STAT_TYPE_HEADER renamed to UCD_STAT_TYPE_HEADER in @ucdjs/env

    This file imports the old name which no longer exists after the refactor. Update to:

  2. packages/cli/src/cmd/files/info.ts, line 98 (link)

    syntax: update to use renamed constant UCD_STAT_TYPE_HEADER

  3. packages/cli/test/cmd/files/info.test.ts, line 4 (link)

    syntax: breaking change: import renamed constant

  4. packages/cli/test/cmd/files/info.test.ts, line 35 (link)

    syntax: update to use renamed constant

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

  5. packages/cli/test/cmd/files/info.test.ts, line 59 (link)

    syntax: update to use renamed constant

  6. packages/cli/test/cmd/files/info.test.ts, line 81 (link)

    syntax: update to use renamed constant

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

  7. packages/cli/test/cmd/files/info.test.ts, line 126 (link)

    syntax: update to use renamed constant

  8. apps/web/src/apis/files.ts, line 5 (link)

    logic: inconsistent header name hardcoded

    This should import from @ucdjs/env for consistency and use the new standardized name. The header value also needs to match the API's new X-UCD-Stat-Type name:

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

  9. apps/web/src/apis/files.ts, line 23 (link)

    style: use imported constant instead of local duplicate

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

4 files reviewed, 9 comments

Edit Code Review Agent Settings | Greptile

@luxass luxass enabled auto-merge January 5, 2026 16:10
@github-actions github-actions bot added the pkg: cli Changes related to the CLI package. label Jan 5, 2026
@luxass luxass merged commit 81772da into main Jan 5, 2026
25 checks passed
@luxass luxass deleted the feat/add-new-headers-for-api branch January 5, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apps: api Changes related to the API. pkg: cli Changes related to the CLI package. pkg: env Changes related to the Env package.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants