Skip to content

Overhaul internal structure and improve typesafety#511

Merged
yamcodes merged 16 commits intomainfrom
501-improve-input-types
Dec 8, 2025
Merged

Overhaul internal structure and improve typesafety#511
yamcodes merged 16 commits intomainfrom
501-improve-input-types

Conversation

@yamcodes
Copy link
Owner

@yamcodes yamcodes commented Dec 8, 2025

Closes #501

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Resolved "Type instantiation is excessively deep and possibly infinite" errors when plugins are used with complex ArkType schemas.
  • New Features

    • Enhanced type inference system for improved environment variable validation accuracy across plugins.
  • Chores

    • Internal type system refactoring and workspace dependency restructuring.

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

…introducing `SchemaShape` and `EnvSchemaWithType` across packages.
@yamcodes yamcodes linked an issue Dec 8, 2025 that may be closed by this pull request
@changeset-bot
Copy link

changeset-bot bot commented Dec 8, 2025

🦋 Changeset detected

Latest commit: aa0027f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@arkenv/vite-plugin Patch
@arkenv/bun-plugin Patch
@repo/types Patch

Not sure what this means? Click here to learn what changesets are.

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

@vercel
Copy link

vercel bot commented Dec 8, 2025

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

Project Deployment Preview Comments Updated (UTC)
arkenv Ready Ready Preview Comment Dec 8, 2025 8:36pm

@github-actions github-actions bot added docs Improvements or additions to documentation arkenv Changes to the `arkenv` npm package. @arkenv/vite-plugin Issues or Pull Requests involving the Vite plugin for ArkEnv tests This issue or PR is about adding, removing or changing tests labels Dec 8, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 8, 2025

Walkthrough

Introduces two new internal packages (@repo/scope and @repo/keywords), creates new schema-related types (EnvSchemaWithType and SchemaShape) in @repo/types, and updates createEnv/arkenv function overloads across plugins to accept both ArkType type() definitions and plain schema objects using improved generic typing. Refactors import paths from local modules to workspace packages.

Changes

Cohort / File(s) Summary
Type System Additions
packages/internal/types/src/schema.ts, packages/internal/types/src/index.ts
Introduces SchemaShape (record type), EnvSchemaWithType (ArkType Type alias), and InferType exports; broadens re-exports from infer-type module.
Core Type Updates
packages/arkenv/src/create-env.ts
Adds public EnvSchema<def> type alias, updates createEnv overloads to accept EnvSchemaWithType and SchemaShape-constrained EnvSchema<T>, introduces distill.Out return type wrapping, shifts to at.infer namespace.
Plugin Type Signature Updates
packages/vite-plugin/src/index.ts, packages/bun-plugin/src/index.ts
Updates arkenv/processEnvSchema function overloads with SchemaShape constraint and EnvSchemaWithType support; adds generic typing to invocations; refines casts from Record<string, unknown> to SchemaShape.
Plugin Tests
packages/arkenv/src/create-env.test.ts, packages/bun-plugin/src/index.test.ts
Replaces envSchema references with type({...}) definitions (Env); updates createEnv calls to pass new schema types; removes explicit type annotations for inferred types.
Internal Packages Setup
packages/internal/scope/*, packages/internal/keywords/*
Creates two new internal packages with TypeScript/Vitest/Turbo configuration; @repo/scope re-exports from @repo/keywords, enabling centralized ArkType scope management.
Module Import Refactoring
packages/arkenv/src/type.ts, packages/internal/scope/src/index.ts
Updates import paths from local ./scope / ./types to workspace package @repo/scope / @repo/keywords.
Manifest & Configuration Updates
packages/internal/types/package.json, packages/arkenv/package.json, pnpm-workspace.yaml, arkenv.code-workspace, .gitignore, .github/workflows/test.yml
Adds new workspace dependencies (@repo/scope, @repo/keywords), workspace folder entries, esbuild-why*.html ignore pattern, and pre-test build step; reorganizes pnpm overrides.
Documentation
packages/internal/types/README.md, packages/internal/keywords/README.md, packages/internal/scope/README.md
Updates README wording to reference ArkType; adds new README files for internal packages.
Changeset Entries
.changeset/smooth-lamps-go.md, .changeset/twelve-tigers-sell.md
Documents patch releases for plugins fixing deep type instantiation errors and introduces new SchemaShape/EnvSchemaWithType types in @repo/types.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Type system changes in packages/arkenv/src/create-env.ts: Review new overloads, SchemaShape constraint, distill.Out wrapping, and at.infer namespace shift.
  • Plugin overload updates: Verify arkenv and processEnvSchema generic typing consistency across vite-plugin and bun-plugin.
  • Internal packages structure: Confirm new @repo/scope and @repo/keywords packages are properly configured with correct exports and dependencies.
  • Import path migrations: Ensure all refactored imports from local to workspace packages are correctly resolved.
  • Test updates: Validate test changes align with new type definitions and createEnv invocation patterns.

Possibly related PRs

Suggested labels

@arkenv/vite-plugin, @arkenv/bun-plugin, @repo/types, types, refactor

Poem

🐰 New types hop into place with grace,
SchemaShape and EnvSchemaWithType race,
Internal scopes and keywords align,
Overloads refined, type safety divine—
ArkType's power now shines through!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'Overhaul internal structure and improve typesafety' clearly and directly summarizes the main changes: restructuring internal packages and enhancing type safety across the codebase.
Linked Issues check ✅ Passed The PR successfully addresses issue #501's objective to improve input types for createEnv/arkenv and type functions by introducing EnvSchemaWithType and SchemaShape, updating createEnv signatures with better type constraints, and improving type inference across plugins.
Out of Scope Changes check ✅ Passed While the PR introduces new internal packages (@repo/scope and @repo/keywords) beyond the stated objective, these changes directly support the type-safety improvements by extracting and organizing shared type utilities, representing a focused expansion rather than unrelated scope creep.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 501-improve-input-types

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e48acea and aa0027f.

📒 Files selected for processing (1)
  • .github/workflows/test.yml (1 hunks)
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/scope.ts : Define custom types in `scope.ts` using ArkType's scoped type system for reusability across schemas
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Keep environment variable schemas readable and TypeScript-like using ArkType syntax
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's built-in types (e.g., `string.host`, `number.port`) where possible in environment schemas
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use the scoped `$` type system for custom types defined in `scope.ts`
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use ArkType's `type()` function to define schemas in environment variable definitions
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use union types for enums in ArkType schemas (e.g., `"'dev' | 'prod'"`) instead of separate enum definitions
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's type inference for TypeScript types instead of manual type definitions
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Convert ArkType validation errors to `ArkEnvError` for user-friendly error messages that include variable name and expected type
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to packages/arkenv/src/**/*.ts : Main library implementation should be in `src/create-env.ts`, built-in validators in `src/types.ts`, error handling in `src/errors.ts`, and utilities in `src/utils.ts`
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use `createEnv(schema)` as the main function for validated environment objects, available as the default export
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Always run `pnpm changeset` for version bumps in published packages - never skip changesets

Applied to files:

  • .github/workflows/test.yml
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to pnpm-workspace.yaml : Use pnpm for package management with workspace support

Applied to files:

  • .github/workflows/test.yml
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Only packages in packages/ directory are published to npm; publishing is handled by changesets using pnpm release

Applied to files:

  • .github/workflows/test.yml
📚 Learning: 2025-11-29T08:00:08.044Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/pnpm.mdc:0-0
Timestamp: 2025-11-29T08:00:08.044Z
Learning: Applies to package.json : Configure only built dependencies (native modules) in `pnpm.onlyBuiltDependencies`, including: biomejs/biome, sentry/cli, swc/core, tailwindcss/oxide, vercel/speed-insights, esbuild, and sharp

Applied to files:

  • .github/workflows/test.yml
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Applies to tooling/*/package.json : Tooling in tooling/ directory contains development and testing tools that are not published to npm and excluded from changesets

Applied to files:

  • .github/workflows/test.yml
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Applies to packages/*/package.json : Packages in packages/ directory must be published to npm and require changesets for versioning, proper exports, and type definitions

Applied to files:

  • .github/workflows/test.yml
⏰ 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). (2)
  • GitHub Check: test-e2e (e2e)
  • GitHub Check: test-e2e (a11y)
🔇 Additional comments (1)
.github/workflows/test.yml (1)

36-37: Verify the pnpm filter syntax for building packages.

The filter syntax --filter=./packages/* does not match standard pnpm-filter patterns documented in the pnpm handbook. Standard patterns are package names (e.g., --filter=@repo/arkenv), paths without globs (e.g., --filter=./packages), or explicit patterns with ellipsis (e.g., --filter=www...).

If the intent is to build all packages in the packages/ directory, consider:

  • pnpm run build (without filter, builds everything in workspace)
  • --filter="./packages/**" (recursive glob pattern, if supported by your pnpm version)

Confirm the filter syntax works as intended before merging.


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.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 8, 2025

Open in StackBlitz

npm i https://pkg.pr.new/arkenv@511
npm i https://pkg.pr.new/@arkenv/bun-plugin@511
npm i https://pkg.pr.new/@arkenv/vite-plugin@511

commit: aa0027f

@arkenv-bot
Copy link
Contributor

arkenv-bot bot commented Dec 8, 2025

📦 Bundle Size Report

Package Size Limit Diff Status
@arkenv/bun-plugin 1.43 kB 2 kB 0.0%
@arkenv/vite-plugin 887 B 2 kB -0.4%
arkenv 728 B 2 kB +0.4%

All size limits passed!

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: 2

🧹 Nitpick comments (3)
packages/internal/types/src/schema.ts (1)

1-5: Add JSDoc comments for public type APIs.

These types form the public API foundation for schema definitions across the codebase. Consider adding JSDoc comments to document:

  • Purpose of SchemaShape (represents an object with string keys and unknown values)
  • Purpose of EnvSchemaWithType (the full ArkType schema type including validation methods)
  • Usage examples showing how these types integrate with createEnv and plugin APIs

Example:

 import { type } from "arktype";

+/**
+ * Runtime ArkType schema representing an object with string keys and unknown values.
+ * This serves as the base schema shape for environment variable definitions.
+ */
 export const SchemaShape = type({ "[string]": "unknown" });
+
+/**
+ * Type representing the inferred shape from SchemaShape.
+ * Used as a constraint for environment schema objects.
+ */
 export type SchemaShape = typeof SchemaShape.infer;
+
+/**
+ * Type representing an ArkType schema with validation methods.
+ * This is the full schema type including runtime validation capabilities.
+ */
 export type EnvSchemaWithType = typeof SchemaShape;

As per coding guidelines: Use JSDoc comments for public APIs.

packages/vite-plugin/src/index.ts (1)

59-67: Type assertions documented appropriately.

The TODO comment clearly explains why the explicit type parameter and assertion are needed (to avoid TypeScript's "excessively deep" error). The <SchemaShape>env cast on line 67 is the same pattern used in bun-plugin/src/index.ts (line 28), maintaining consistency.

One minor observation: consider extracting the filtering logic into a shared utility if this pattern appears in more plugins in the future.

packages/bun-plugin/src/index.ts (1)

189-189: Consider narrowing the any type for dynamically loaded schemas.

The schema: any declaration loses type safety for dynamically imported schemas. While runtime validation via createEnv will still catch errors, you could add a runtime check before calling processEnvSchema:

-		let schema: any;
+		let schema: EnvSchemaWithType | undefined;

Then validate the loaded module exports a compatible type before use. This would provide clearer error messages if the loaded schema is malformed.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e16ea75 and 5d90caf.

📒 Files selected for processing (11)
  • .changeset/smooth-lamps-go.md (1 hunks)
  • .changeset/twelve-tigers-sell.md (1 hunks)
  • packages/arkenv/src/create-env.test.ts (5 hunks)
  • packages/arkenv/src/create-env.ts (2 hunks)
  • packages/bun-plugin/src/index.test.ts (1 hunks)
  • packages/bun-plugin/src/index.ts (3 hunks)
  • packages/internal/types/README.md (1 hunks)
  • packages/internal/types/package.json (1 hunks)
  • packages/internal/types/src/index.ts (1 hunks)
  • packages/internal/types/src/schema.ts (1 hunks)
  • packages/vite-plugin/src/index.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
packages/arkenv/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/arktype.mdc)

packages/arkenv/**/*.ts: Use ArkType's type() function to define schemas in environment variable definitions
Leverage ArkType's type inference for TypeScript types instead of manual type definitions
Use the scoped $ type system for custom types defined in scope.ts
Keep environment variable schemas readable and TypeScript-like using ArkType syntax
Use union types for enums in ArkType schemas (e.g., "'dev' | 'prod'") instead of separate enum definitions
Leverage ArkType's built-in types (e.g., string.host, number.port) where possible in environment schemas
Convert ArkType validation errors to ArkEnvError for user-friendly error messages that include variable name and expected type

Files:

  • packages/arkenv/src/create-env.test.ts
  • packages/arkenv/src/create-env.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

**/*.{ts,tsx}: Prefer type over interface for type definitions in TypeScript
Use TypeScript 5.1+ features when appropriate
Leverage const type parameters for better inference in TypeScript
Use JSDoc comments for public APIs
Use tabs for indentation (configured in Biome)
Use double quotes for strings (configured in Biome)
Organize imports automatically (Biome handles this)
Avoid explicit types when TypeScript can infer them (noInferrableTypes error)
Use as const where appropriate for immutable values (useAsConstAssertion error)
Don't reassign function parameters (noParameterAssign error)
Place default parameters last in function signatures (useDefaultParameterLast error)
Always initialize enum values (useEnumInitializers error)
Declare one variable per statement (useSingleVarDeclarator error)
Avoid unnecessary template literals (noUnusedTemplateLiteral error)
Prefer Number.parseInt over global parseInt (useNumberNamespace error)
Use kebab-case for TypeScript filenames (e.g., create-env.ts)
Use camelCase for function names (e.g., createEnv)
Use PascalCase for type names (e.g., ArkEnvError)
Use UPPER_SNAKE_CASE for environment variables and constants
Include examples in JSDoc comments when helpful for public APIs
Document complex type logic with JSDoc comments
Use ArkEnvError for environment variable validation errors
Provide clear, actionable error messages that include the variable name and expected type

**/*.{ts,tsx}: Use createEnv(schema) as the main function for validated environment objects, available as the default export
Use built-in validators (host, port, url, email) from src/types.ts when available instead of custom validation
Use ArkEnvError for environment variable errors, not generic errors
Environment schema definitions should use built-in validators, ArkType string literals, and support default values in the schema pattern
Use logical grouping for related environment variables in schemas
Use descriptive env...

Files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
  • packages/bun-plugin/src/index.test.ts
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/src/create-env.ts
  • packages/internal/types/src/index.ts
  • packages/bun-plugin/src/index.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

Co-locate tests with components: Component.tsx next to Component.test.tsx

**/*.test.{ts,tsx}: Test individual functions, components, and hooks in isolation with mocked dependencies in unit tests
Keep unit tests fast with execution under 100ms per test
Co-locate unit tests with source files using naming convention: source.tssource.test.ts
Focus component tests on public API, user behavior, state transitions, and accessibility rather than styling or implementation details
Query component tests by role, name, label, and text using accessibility-first selectors
Use Vitest as the test framework for unit and integration tests
Use Testing Library with user-event for real user simulation in component tests

**/*.test.{ts,tsx}: Test individual functions, components, and hooks in isolation with mocked dependencies using the *.test.ts or *.test.tsx suffix
Mock process.env in tests for different scenarios and save/restore original env in beforeEach/afterEach hooks
Use Vitest's describe/it structure in test files
Test edge cases including invalid and missing environment variable values
Use Vitest for testing framework

Files:

  • packages/arkenv/src/create-env.test.ts
  • packages/bun-plugin/src/index.test.ts
packages/arkenv/src/**/*.ts

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Main library implementation should be in src/create-env.ts, built-in validators in src/types.ts, error handling in src/errors.ts, and utilities in src/utils.ts

Files:

  • packages/arkenv/src/create-env.test.ts
  • packages/arkenv/src/create-env.ts
**/*.{ts,tsx,json,md}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use Biome for linting and formatting instead of ESLint and Prettier

Files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
  • packages/internal/types/README.md
  • packages/internal/types/package.json
  • packages/bun-plugin/src/index.test.ts
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/src/create-env.ts
  • packages/internal/types/src/index.ts
  • packages/bun-plugin/src/index.ts
**/README.md

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Document environment requirements in README files

Files:

  • packages/internal/types/README.md
**/package.json

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Use workspace:* protocol for workspace dependencies between packages

Files:

  • packages/internal/types/package.json
{packages,apps,tooling}/**/package.json

📄 CodeRabbit inference engine (.cursor/rules/pnpm.mdc)

When referencing workspace packages in dependencies, use the workspace:* protocol instead of version numbers

Files:

  • packages/internal/types/package.json
**/index.ts

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

Use barrel exports (index.ts) for package entry points

Files:

  • packages/vite-plugin/src/index.ts
  • packages/internal/types/src/index.ts
  • packages/bun-plugin/src/index.ts
🧠 Learnings (40)
📓 Common learnings
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Keep environment variable schemas readable and TypeScript-like using ArkType syntax
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's built-in types (e.g., `string.host`, `number.port`) where possible in environment schemas
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use ArkType's `type()` function to define schemas in environment variable definitions
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use `createEnv(schema)` as the main function for validated environment objects, available as the default export
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use union types for enums in ArkType schemas (e.g., `"'dev' | 'prod'"`) instead of separate enum definitions
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/scope.ts : Define custom types in `scope.ts` using ArkType's scoped type system for reusability across schemas
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Convert ArkType validation errors to `ArkEnvError` for user-friendly error messages that include variable name and expected type
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: ArkType validates environment variables at runtime and TypeScript types are inferred from the schema definition
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Environment schema definitions should use built-in validators, ArkType string literals, and support default values in the schema pattern
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use logical grouping for related environment variables in schemas
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Keep environment variable schemas readable and TypeScript-like using ArkType syntax

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
  • .changeset/twelve-tigers-sell.md
  • .changeset/smooth-lamps-go.md
  • packages/internal/types/README.md
  • packages/internal/types/package.json
  • packages/bun-plugin/src/index.test.ts
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/src/create-env.ts
  • packages/internal/types/src/index.ts
  • packages/bun-plugin/src/index.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use `createEnv(schema)` as the main function for validated environment objects, available as the default export

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
  • packages/bun-plugin/src/index.test.ts
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/src/create-env.ts
  • packages/bun-plugin/src/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's built-in types (e.g., `string.host`, `number.port`) where possible in environment schemas

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
  • .changeset/smooth-lamps-go.md
  • packages/internal/types/README.md
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/src/create-env.ts
  • packages/internal/types/src/index.ts
  • packages/bun-plugin/src/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Convert ArkType validation errors to `ArkEnvError` for user-friendly error messages that include variable name and expected type

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
  • .changeset/smooth-lamps-go.md
  • packages/internal/types/README.md
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/src/create-env.ts
  • packages/internal/types/src/index.ts
  • packages/bun-plugin/src/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use ArkType's `type()` function to define schemas in environment variable definitions

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
  • .changeset/twelve-tigers-sell.md
  • .changeset/smooth-lamps-go.md
  • packages/internal/types/README.md
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/src/create-env.ts
  • packages/internal/types/src/index.ts
  • packages/bun-plugin/src/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use union types for enums in ArkType schemas (e.g., `"'dev' | 'prod'"`) instead of separate enum definitions

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
  • .changeset/smooth-lamps-go.md
  • packages/internal/types/README.md
  • packages/internal/types/package.json
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/src/create-env.ts
  • packages/internal/types/src/index.ts
  • packages/bun-plugin/src/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's type inference for TypeScript types instead of manual type definitions

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
  • .changeset/smooth-lamps-go.md
  • packages/internal/types/README.md
  • packages/internal/types/package.json
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/src/create-env.ts
  • packages/internal/types/src/index.ts
  • packages/bun-plugin/src/index.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to packages/arkenv/src/**/*.ts : Main library implementation should be in `src/create-env.ts`, built-in validators in `src/types.ts`, error handling in `src/errors.ts`, and utilities in `src/utils.ts`

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/README.md
  • packages/internal/types/package.json
  • packages/bun-plugin/src/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: ArkType validates environment variables at runtime and TypeScript types are inferred from the schema definition

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
  • packages/internal/types/README.md
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/src/create-env.ts
  • packages/internal/types/src/index.ts
  • packages/bun-plugin/src/index.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use `ArkEnvError` for environment variable errors, not generic errors

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/src/create-env.ts
  • packages/bun-plugin/src/index.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.test.{ts,tsx} : Mock `process.env` in tests for different scenarios and save/restore original env in `beforeEach`/`afterEach` hooks

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/bun-plugin/src/index.test.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.test.{ts,tsx} : Test edge cases including invalid and missing environment variable values

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/bun-plugin/src/index.test.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Environment schema definitions should use built-in validators, ArkType string literals, and support default values in the schema pattern

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
  • .changeset/smooth-lamps-go.md
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/src/create-env.ts
  • packages/internal/types/src/index.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use logical grouping for related environment variables in schemas

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/vite-plugin/src/index.ts
  • packages/bun-plugin/src/index.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use `ArkEnvError` for environment variable validation errors

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/src/create-env.ts
  • packages/bun-plugin/src/index.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/scope.ts : Define custom types in `scope.ts` using ArkType's scoped type system for reusability across schemas

Applied to files:

  • packages/internal/types/src/schema.ts
  • .changeset/twelve-tigers-sell.md
  • .changeset/smooth-lamps-go.md
  • packages/internal/types/README.md
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/src/create-env.ts
  • packages/internal/types/src/index.ts
  • packages/bun-plugin/src/index.ts
📚 Learning: 2025-11-24T16:04:36.939Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-11-24T16:04:36.939Z
Learning: Achieve coverage goals: environment variable parsing and validation, type checking and error handling, default value handling, custom type validation, plugin integration with Vite, and real project build testing using examples as fixtures

Applied to files:

  • .changeset/smooth-lamps-go.md
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use the scoped `$` type system for custom types defined in `scope.ts`

Applied to files:

  • .changeset/smooth-lamps-go.md
  • packages/internal/types/README.md
  • packages/internal/types/src/index.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use PascalCase for type names (e.g., `ArkEnvError`)

Applied to files:

  • packages/internal/types/README.md
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Applies to packages/*/package.json : Packages in packages/ directory must be published to npm and require changesets for versioning, proper exports, and type definitions

Applied to files:

  • packages/internal/types/package.json
📚 Learning: 2025-11-29T08:00:08.044Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/pnpm.mdc:0-0
Timestamp: 2025-11-29T08:00:08.044Z
Learning: Applies to package.json : The project uses `pnpm10.20.0` as specified in the `packageManager` field

Applied to files:

  • packages/internal/types/package.json
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Applies to **/package.json : Use workspace:* protocol for workspace dependencies between packages

Applied to files:

  • packages/internal/types/package.json
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Always run `pnpm changeset` for version bumps in published packages - never skip changesets

Applied to files:

  • packages/internal/types/package.json
📚 Learning: 2025-11-29T08:00:08.044Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/pnpm.mdc:0-0
Timestamp: 2025-11-29T08:00:08.044Z
Learning: Applies to package.json : Configure only built dependencies (native modules) in `pnpm.onlyBuiltDependencies`, including: biomejs/biome, sentry/cli, swc/core, tailwindcss/oxide, vercel/speed-insights, esbuild, and sharp

Applied to files:

  • packages/internal/types/package.json
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Applies to tooling/*/package.json : Tooling in tooling/ directory contains development and testing tools that are not published to npm and excluded from changesets

Applied to files:

  • packages/internal/types/package.json
📚 Learning: 2025-11-29T08:00:08.044Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/pnpm.mdc:0-0
Timestamp: 2025-11-29T08:00:08.044Z
Learning: Applies to {packages,apps,tooling}/**/package.json : When referencing workspace packages in dependencies, use the `workspace:*` protocol instead of version numbers

Applied to files:

  • packages/internal/types/package.json
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to pnpm-workspace.yaml : Use pnpm for package management with workspace support

Applied to files:

  • packages/internal/types/package.json
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: packages/arkenv should not depend on other workspace packages; packages/vite-plugin depends on arkenv; apps/www may depend on workspace packages

Applied to files:

  • packages/internal/types/package.json
📚 Learning: 2025-11-29T08:00:08.044Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/pnpm.mdc:0-0
Timestamp: 2025-11-29T08:00:08.044Z
Learning: Applies to {package.json,pnpm-lock.yaml,pnpm-workspace.yaml} : Always use `pnpm` for all package management operations in this monorepo (never use `npm` or `yarn` commands), except for standalone example projects in the `examples/` folder

Applied to files:

  • packages/internal/types/package.json
📚 Learning: 2025-11-24T16:04:47.583Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:47.583Z
Learning: Applies to apps/playgrounds/bun-react/**/package.json : Use `bun install` instead of `npm install`, `yarn install`, or `pnpm install` in package.json scripts

Applied to files:

  • packages/internal/types/package.json
📚 Learning: 2025-11-29T08:57:24.056Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: examples/with-bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-29T08:57:24.056Z
Learning: Applies to examples/with-bun-react/**/*.test.{ts,tsx,js,jsx} : Use test syntax from `bun:test` with `test` and `expect` functions

Applied to files:

  • packages/bun-plugin/src/index.test.ts
📚 Learning: 2025-11-24T16:04:47.583Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:47.583Z
Learning: Applies to apps/playgrounds/bun-react/**/*.test.{ts,tsx,js,jsx} : Use `bun:test` for unit and integration testing with `test` and `expect` from the built-in test module

Applied to files:

  • packages/bun-plugin/src/index.test.ts
📚 Learning: 2025-11-29T08:57:24.056Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: examples/with-bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-29T08:57:24.056Z
Learning: Applies to examples/with-bun-react/**/*.test.{ts,tsx,js,jsx} : Use `bun test` instead of `jest` or `vitest` for running tests

Applied to files:

  • packages/bun-plugin/src/index.test.ts
📚 Learning: 2025-11-24T16:04:58.629Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:58.629Z
Learning: Applies to apps/playgrounds/bun/**/*.test.{ts,tsx,js,jsx} : Use `import { test, expect } from "bun:test"` for writing tests

Applied to files:

  • packages/bun-plugin/src/index.test.ts
📚 Learning: 2025-11-24T16:04:58.629Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:58.629Z
Learning: Applies to apps/playgrounds/bun/**/*.test.{ts,tsx,js,jsx} : Use `bun test` instead of `jest` or `vitest` for running tests

Applied to files:

  • packages/bun-plugin/src/index.test.ts
📚 Learning: 2025-11-24T16:04:47.583Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:47.583Z
Learning: Applies to apps/playgrounds/bun-react/**/*.test.{ts,tsx,js,jsx} : Use `bun test` instead of `jest` or `vitest` for running tests

Applied to files:

  • packages/bun-plugin/src/index.test.ts
📚 Learning: 2025-11-24T16:04:58.629Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:58.629Z
Learning: Applies to apps/playgrounds/bun/**/*.{ts,tsx,js,jsx} : Bun automatically loads .env files, so don't use `dotenv` library

Applied to files:

  • packages/bun-plugin/src/index.test.ts
  • packages/bun-plugin/src/index.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/index.ts : Use barrel exports (`index.ts`) for package entry points

Applied to files:

  • packages/internal/types/src/index.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Leverage `const` type parameters for better inference in TypeScript

Applied to files:

  • packages/internal/types/src/index.ts
🧬 Code graph analysis (4)
packages/internal/types/src/schema.ts (3)
packages/arkenv/src/type.ts (1)
  • type (3-3)
packages/arkenv/src/type.test.ts (7)
  • it (4-218)
  • envType (29-47)
  • envType (86-108)
  • envType (202-217)
  • envType (171-190)
  • envType (5-9)
  • envType (17-21)
packages/arkenv/src/scope.test.ts (1)
  • stringType (46-50)
packages/bun-plugin/src/index.test.ts (2)
packages/arkenv/src/index.test.ts (2)
  • vi (65-81)
  • vi (25-35)
packages/arkenv/src/type.test.ts (3)
  • envType (5-9)
  • envType (29-47)
  • envType (171-190)
packages/vite-plugin/src/index.ts (3)
packages/bun-plugin/src/index.ts (1)
  • arkenv (131-142)
packages/internal/types/src/schema.ts (3)
  • SchemaShape (3-3)
  • SchemaShape (4-4)
  • EnvSchemaWithType (5-5)
packages/arkenv/src/create-env.ts (2)
  • EnvSchema (7-7)
  • createEnv (35-53)
packages/arkenv/src/create-env.ts (3)
packages/arkenv/src/scope.ts (1)
  • $ (9-19)
packages/internal/types/src/schema.ts (3)
  • SchemaShape (3-3)
  • SchemaShape (4-4)
  • EnvSchemaWithType (5-5)
packages/internal/types/src/infer-type.ts (1)
  • InferType (9-17)
⏰ 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). (2)
  • GitHub Check: test-e2e (a11y)
  • GitHub Check: test-e2e (e2e)
🔇 Additional comments (15)
packages/internal/types/README.md (1)

3-3: LGTM!

Documentation updated appropriately to reflect ArkType integration in the internal types package.

Also applies to: 7-7

.changeset/smooth-lamps-go.md (1)

1-8: LGTM!

Changeset appropriately documents the type stability improvements for the plugin packages.

packages/bun-plugin/src/index.test.ts (1)

57-57: LGTM!

The as const assertion improves type inference for the environment schema, ensuring literal types are preserved with the new SchemaShape-based type system.

.changeset/twelve-tigers-sell.md (1)

1-7: LGTM!

Changeset appropriately documents the addition of new schema types to the internal types package.

packages/internal/types/src/index.ts (1)

9-12: LGTM!

Barrel export pattern is appropriate for the package entry point, consolidating type exports from sub-modules.

packages/internal/types/src/schema.ts (1)

3-3: The ArkType index signature syntax is correct. The pattern "[string]": "unknown" is the correct ArkType syntax for defining an object with arbitrary string keys and values of type unknown, mirroring TypeScript's {[key: string]: unknown} syntax. No changes needed.

packages/vite-plugin/src/index.ts (2)

1-2: LGTM!

The imports are correctly updated to bring in the new type definitions from @repo/types, aligning with the centralized type system introduced in this PR.


43-49: Function overloads are well-structured.

The overload pattern correctly supports both EnvSchema<T> for literal schema objects and EnvSchemaWithType for pre-defined ArkType schemas. This mirrors the approach in create-env.ts and bun-plugin, maintaining consistency across the codebase.

packages/arkenv/src/create-env.ts (3)

1-7: Type system foundation is well-designed.

The EnvSchema<def> type alias using at.validate<def, (typeof $)["t"]> correctly integrates with ArkType's validation system and the project's custom scope. This provides compile-time schema validation while maintaining the readability goals from the coding guidelines.


23-38: Overload structure provides good type inference.

The three overloads handle the key use cases:

  1. Raw schema objects with const T for literal type inference
  2. Pre-built EnvSchemaWithType for dynamic schemas
  3. Implementation signature accepting both

The const T extends SchemaShape constraint with distill.Out return type ensures proper type narrowing. This aligns with ArkType's type inference patterns as noted in the learnings.


41-52: Runtime schema detection is correct.

The check typeof def === "function" && "assert" in def properly distinguishes ArkType instances from raw schema objects. The use of $.type.raw() for plain objects integrates with the scoped type system defined in scope.ts.

Error handling correctly throws ArkEnvError for validation failures, as required by the coding guidelines.

packages/bun-plugin/src/index.ts (4)

2-4: LGTM!

Imports are correctly updated to include the new centralized types from @repo/types, consistent with the other plugin packages.


12-37: Helper function is well-structured with clear documentation.

The processEnvSchema function correctly:

  • Uses the generic T extends SchemaShape constraint
  • Documents the type assertion workaround with a TODO
  • Filters environment variables by the BUN_PUBLIC_ prefix
  • Returns a properly typed Map<string, string>

The explicit type parameter createEnv<T>(options, process.env) on line 21 mirrors the approach in vite-plugin, maintaining consistency.


89-92: Generic catch is appropriate here.

The empty catch block handles any file read errors gracefully by returning undefined, allowing Bun to handle the file with its default behavior. This is a reasonable fallback for a build plugin.


127-134: Function overloads match the established pattern.

The overload structure is consistent with vite-plugin and create-env.ts, supporting both EnvSchema<T> and EnvSchemaWithType. The explicit <T> parameter on processEnvSchema<T>(options) correctly propagates the type.

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: 3

Caution

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

⚠️ Outside diff range comments (1)
pnpm-workspace.yaml (1)

1-6: Remove workspace dependencies from packages/arkenv.

packages/arkenv violates the workspace constraint by depending on internal workspace packages (@repo/keywords, @repo/scope, @repo/types) in devDependencies. Per the monorepo rules, packages/arkenv should not depend on other workspace packages. Either these dependencies must be moved to production code with proper exports, or the internal packages should be inlined into arkenv's source.

♻️ Duplicate comments (1)
packages/internal/scope/tsdown.config.ts (1)

1-10: Configuration duplication noted.

This configuration is identical to packages/internal/keywords/tsdown.config.ts. See the review comment on that file for a suggested refactoring approach to extract shared configuration.

🧹 Nitpick comments (2)
packages/internal/keywords/tsdown.config.ts (1)

1-10: Consider extracting shared tsdown configuration.

This configuration is identical to packages/internal/scope/tsdown.config.ts. Consider creating a shared base configuration to follow DRY principles and simplify maintenance.

Example approach - create a shared config file:

// packages/internal/shared-tsdown.config.ts
import { defineConfig } from "tsdown";

export const sharedConfig = defineConfig({
	format: ["esm", "cjs"],
	minify: true,
	fixedExtension: false,
	dts: {
		resolve: ["@repo/types"],
	},
	sourcemap: false, // if consistency is desired
});

Then import and extend in each package config:

import { sharedConfig } from "../shared-tsdown.config";

export default sharedConfig;
packages/vite-plugin/src/index.ts (1)

6-20: InferType appears to duplicate @repo/types definition.

The InferType utility type defined here (lines 10-18) mirrors the implementation in packages/internal/types/src/infer-type.ts. Consider importing from @repo/types to maintain a single source of truth.

-import type { EnvSchemaWithType, SchemaShape } from "@repo/types";
+import type { EnvSchemaWithType, InferType, SchemaShape } from "@repo/types";
 import { createEnv, type EnvSchema } from "arkenv";
 import type { type } from "arktype";
 import { loadEnv, type Plugin } from "vite";

-/**
- * Extract the inferred type from an ArkType type definition by checking its call signature.
- * When a type definition is called, it returns either the validated value or type.errors.
- */
-type InferType<T> = T extends (
-	value: Record<string, string | undefined>,
-) => infer R
-	? R extends type.errors
-		? never
-		: R
-	: T extends type.Any<infer U, infer _Scope>
-		? U
-		: never;
-
 export type ImportMetaEnvAugmented<T> = InferType<T>;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5d90caf and 4993d8b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (29)
  • .gitignore (1 hunks)
  • arkenv.code-workspace (1 hunks)
  • packages/arkenv/.gitignore (0 hunks)
  • packages/arkenv/package.json (1 hunks)
  • packages/arkenv/package/LICENSE (1 hunks)
  • packages/arkenv/package/README.md (1 hunks)
  • packages/arkenv/package/package.json (1 hunks)
  • packages/arkenv/src/create-env.ts (2 hunks)
  • packages/arkenv/src/type.ts (1 hunks)
  • packages/arkenv/tsdown.config.ts (1 hunks)
  • packages/bun-plugin/src/index.ts (3 hunks)
  • packages/internal/keywords/README.md (1 hunks)
  • packages/internal/keywords/package.json (1 hunks)
  • packages/internal/keywords/src/index.test.ts (1 hunks)
  • packages/internal/keywords/tsconfig.json (1 hunks)
  • packages/internal/keywords/tsdown.config.ts (1 hunks)
  • packages/internal/keywords/turbo.json (1 hunks)
  • packages/internal/keywords/vitest.config.ts (1 hunks)
  • packages/internal/scope/README.md (1 hunks)
  • packages/internal/scope/package.json (1 hunks)
  • packages/internal/scope/src/index.test.ts (1 hunks)
  • packages/internal/scope/src/index.ts (1 hunks)
  • packages/internal/scope/tsconfig.json (1 hunks)
  • packages/internal/scope/tsdown.config.ts (1 hunks)
  • packages/internal/scope/turbo.json (1 hunks)
  • packages/internal/scope/vitest.config.ts (1 hunks)
  • packages/internal/types/src/schema.ts (1 hunks)
  • packages/vite-plugin/src/index.ts (4 hunks)
  • pnpm-workspace.yaml (2 hunks)
💤 Files with no reviewable changes (1)
  • packages/arkenv/.gitignore
✅ Files skipped from review due to trivial changes (7)
  • packages/internal/scope/src/index.test.ts
  • packages/internal/keywords/README.md
  • packages/internal/scope/README.md
  • packages/arkenv/package/LICENSE
  • packages/arkenv/package/package.json
  • packages/internal/keywords/tsconfig.json
  • arkenv.code-workspace
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/internal/types/src/schema.ts
🧰 Additional context used
📓 Path-based instructions (12)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

**/*.{ts,tsx}: Prefer type over interface for type definitions in TypeScript
Use TypeScript 5.1+ features when appropriate
Leverage const type parameters for better inference in TypeScript
Use JSDoc comments for public APIs
Use tabs for indentation (configured in Biome)
Use double quotes for strings (configured in Biome)
Organize imports automatically (Biome handles this)
Avoid explicit types when TypeScript can infer them (noInferrableTypes error)
Use as const where appropriate for immutable values (useAsConstAssertion error)
Don't reassign function parameters (noParameterAssign error)
Place default parameters last in function signatures (useDefaultParameterLast error)
Always initialize enum values (useEnumInitializers error)
Declare one variable per statement (useSingleVarDeclarator error)
Avoid unnecessary template literals (noUnusedTemplateLiteral error)
Prefer Number.parseInt over global parseInt (useNumberNamespace error)
Use kebab-case for TypeScript filenames (e.g., create-env.ts)
Use camelCase for function names (e.g., createEnv)
Use PascalCase for type names (e.g., ArkEnvError)
Use UPPER_SNAKE_CASE for environment variables and constants
Include examples in JSDoc comments when helpful for public APIs
Document complex type logic with JSDoc comments
Use ArkEnvError for environment variable validation errors
Provide clear, actionable error messages that include the variable name and expected type

**/*.{ts,tsx}: Use createEnv(schema) as the main function for validated environment objects, available as the default export
Use built-in validators (host, port, url, email) from src/types.ts when available instead of custom validation
Use ArkEnvError for environment variable errors, not generic errors
Environment schema definitions should use built-in validators, ArkType string literals, and support default values in the schema pattern
Use logical grouping for related environment variables in schemas
Use descriptive env...

Files:

  • packages/internal/scope/vitest.config.ts
  • packages/arkenv/src/type.ts
  • packages/arkenv/tsdown.config.ts
  • packages/internal/keywords/src/index.test.ts
  • packages/internal/keywords/tsdown.config.ts
  • packages/bun-plugin/src/index.ts
  • packages/internal/scope/src/index.ts
  • packages/internal/scope/tsdown.config.ts
  • packages/vite-plugin/src/index.ts
  • packages/internal/keywords/vitest.config.ts
  • packages/arkenv/src/create-env.ts
**/*.{ts,tsx,json,md}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use Biome for linting and formatting instead of ESLint and Prettier

Files:

  • packages/internal/scope/vitest.config.ts
  • packages/internal/scope/turbo.json
  • packages/arkenv/src/type.ts
  • packages/arkenv/tsdown.config.ts
  • packages/internal/scope/tsconfig.json
  • packages/internal/keywords/src/index.test.ts
  • packages/internal/keywords/tsdown.config.ts
  • packages/bun-plugin/src/index.ts
  • packages/internal/scope/src/index.ts
  • packages/arkenv/package/README.md
  • packages/internal/keywords/package.json
  • packages/internal/scope/package.json
  • packages/internal/scope/tsdown.config.ts
  • packages/vite-plugin/src/index.ts
  • packages/internal/keywords/turbo.json
  • packages/internal/keywords/vitest.config.ts
  • packages/arkenv/package.json
  • packages/arkenv/src/create-env.ts
packages/arkenv/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/arktype.mdc)

packages/arkenv/**/*.ts: Use ArkType's type() function to define schemas in environment variable definitions
Leverage ArkType's type inference for TypeScript types instead of manual type definitions
Use the scoped $ type system for custom types defined in scope.ts
Keep environment variable schemas readable and TypeScript-like using ArkType syntax
Use union types for enums in ArkType schemas (e.g., "'dev' | 'prod'") instead of separate enum definitions
Leverage ArkType's built-in types (e.g., string.host, number.port) where possible in environment schemas
Convert ArkType validation errors to ArkEnvError for user-friendly error messages that include variable name and expected type

Files:

  • packages/arkenv/src/type.ts
  • packages/arkenv/tsdown.config.ts
  • packages/arkenv/src/create-env.ts
packages/arkenv/src/**/*.ts

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Main library implementation should be in src/create-env.ts, built-in validators in src/types.ts, error handling in src/errors.ts, and utilities in src/utils.ts

Files:

  • packages/arkenv/src/type.ts
  • packages/arkenv/src/create-env.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

Co-locate tests with components: Component.tsx next to Component.test.tsx

**/*.test.{ts,tsx}: Test individual functions, components, and hooks in isolation with mocked dependencies in unit tests
Keep unit tests fast with execution under 100ms per test
Co-locate unit tests with source files using naming convention: source.tssource.test.ts
Focus component tests on public API, user behavior, state transitions, and accessibility rather than styling or implementation details
Query component tests by role, name, label, and text using accessibility-first selectors
Use Vitest as the test framework for unit and integration tests
Use Testing Library with user-event for real user simulation in component tests

**/*.test.{ts,tsx}: Test individual functions, components, and hooks in isolation with mocked dependencies using the *.test.ts or *.test.tsx suffix
Mock process.env in tests for different scenarios and save/restore original env in beforeEach/afterEach hooks
Use Vitest's describe/it structure in test files
Test edge cases including invalid and missing environment variable values
Use Vitest for testing framework

Files:

  • packages/internal/keywords/src/index.test.ts
**/index.ts

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

Use barrel exports (index.ts) for package entry points

Files:

  • packages/bun-plugin/src/index.ts
  • packages/internal/scope/src/index.ts
  • packages/vite-plugin/src/index.ts
**/README.md

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Document environment requirements in README files

Files:

  • packages/arkenv/package/README.md
**/package.json

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Use workspace:* protocol for workspace dependencies between packages

Files:

  • packages/internal/keywords/package.json
  • packages/internal/scope/package.json
  • packages/arkenv/package.json
{packages,apps,tooling}/**/package.json

📄 CodeRabbit inference engine (.cursor/rules/pnpm.mdc)

When referencing workspace packages in dependencies, use the workspace:* protocol instead of version numbers

Files:

  • packages/internal/keywords/package.json
  • packages/internal/scope/package.json
  • packages/arkenv/package.json
{package.json,pnpm-lock.yaml,pnpm-workspace.yaml}

📄 CodeRabbit inference engine (.cursor/rules/pnpm.mdc)

Always use pnpm for all package management operations in this monorepo (never use npm or yarn commands), except for standalone example projects in the examples/ folder

Files:

  • pnpm-workspace.yaml
pnpm-workspace.yaml

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use pnpm for package management with workspace support

Files:

  • pnpm-workspace.yaml
packages/*/package.json

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Packages in packages/ directory must be published to npm and require changesets for versioning, proper exports, and type definitions

Files:

  • packages/arkenv/package.json
🧠 Learnings (68)
📓 Common learnings
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Keep environment variable schemas readable and TypeScript-like using ArkType syntax
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's built-in types (e.g., `string.host`, `number.port`) where possible in environment schemas
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use ArkType's `type()` function to define schemas in environment variable definitions
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's type inference for TypeScript types instead of manual type definitions
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use union types for enums in ArkType schemas (e.g., `"'dev' | 'prod'"`) instead of separate enum definitions
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/scope.ts : Define custom types in `scope.ts` using ArkType's scoped type system for reusability across schemas
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: ArkType validates environment variables at runtime and TypeScript types are inferred from the schema definition
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Convert ArkType validation errors to `ArkEnvError` for user-friendly error messages that include variable name and expected type
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use the scoped `$` type system for custom types defined in `scope.ts`
Learnt from: yamcodes
Repo: yamcodes/arkenv PR: 498
File: apps/playgrounds/node/index.ts:2-2
Timestamp: 2025-12-05T20:33:10.676Z
Learning: ArkType 2.1.28+ supports Standard Schema specification, allowing interoperability with other Standard Schema-compliant validation libraries (e.g., Zod, Valibot) within the same schema definition
📚 Learning: 2025-11-24T16:04:36.939Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-11-24T16:04:36.939Z
Learning: Applies to **/*.test.{ts,tsx} : Use Vitest as the test framework for unit and integration tests

Applied to files:

  • packages/internal/scope/vitest.config.ts
  • packages/internal/keywords/src/index.test.ts
  • pnpm-workspace.yaml
  • packages/internal/keywords/vitest.config.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.test.{ts,tsx} : Use Vitest for testing framework

Applied to files:

  • packages/internal/scope/vitest.config.ts
  • packages/internal/keywords/src/index.test.ts
  • pnpm-workspace.yaml
  • packages/internal/keywords/vitest.config.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.test.{ts,tsx} : Use Vitest's `describe`/`it` structure in test files

Applied to files:

  • packages/internal/scope/vitest.config.ts
  • packages/internal/keywords/src/index.test.ts
  • packages/internal/keywords/vitest.config.ts
📚 Learning: 2025-11-24T16:04:36.939Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-11-24T16:04:36.939Z
Learning: Applies to packages/vite-plugin/src/**/*.test.ts : Use fixture-based testing pattern with `__fixtures__` directory for Vite plugin tests

Applied to files:

  • packages/internal/scope/vitest.config.ts
  • packages/internal/keywords/src/index.test.ts
  • pnpm-workspace.yaml
  • packages/internal/keywords/vitest.config.ts
📚 Learning: 2025-11-24T16:04:36.939Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-11-24T16:04:36.939Z
Learning: Applies to packages/vite-plugin/src/**/*.test.ts : Test Vite plugin using the `with-vite-react-ts` example as a fixture and validate plugin works with real Vite projects

Applied to files:

  • packages/internal/scope/vitest.config.ts
  • packages/internal/keywords/src/index.test.ts
  • pnpm-workspace.yaml
  • packages/internal/keywords/vitest.config.ts
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Applies to turbo.json : Turborepo tasks are defined in turbo.json with common tasks: build, dev, typecheck, test, and test:e2e

Applied to files:

  • packages/internal/scope/turbo.json
  • packages/internal/keywords/turbo.json
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Monorepo directory structure must follow: packages/ (published npm packages), apps/ (applications), examples/ (example projects), tooling/ (development tools), and turbo.json at root

Applied to files:

  • packages/internal/scope/turbo.json
  • packages/internal/keywords/turbo.json
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/scope.ts : Define custom types in `scope.ts` using ArkType's scoped type system for reusability across schemas

Applied to files:

  • packages/arkenv/src/type.ts
  • packages/internal/scope/tsconfig.json
  • packages/bun-plugin/src/index.ts
  • packages/internal/scope/src/index.ts
  • packages/internal/keywords/package.json
  • packages/internal/scope/package.json
  • packages/internal/scope/tsdown.config.ts
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/package.json
  • packages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use the scoped `$` type system for custom types defined in `scope.ts`

Applied to files:

  • packages/arkenv/src/type.ts
  • packages/internal/scope/tsconfig.json
  • packages/internal/scope/src/index.ts
  • packages/internal/keywords/package.json
  • packages/internal/scope/package.json
  • packages/internal/scope/tsdown.config.ts
  • packages/arkenv/package.json
  • packages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's type inference for TypeScript types instead of manual type definitions

Applied to files:

  • packages/arkenv/src/type.ts
  • packages/arkenv/tsdown.config.ts
  • packages/bun-plugin/src/index.ts
  • packages/arkenv/package/README.md
  • packages/internal/keywords/package.json
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Keep environment variable schemas readable and TypeScript-like using ArkType syntax

Applied to files:

  • packages/arkenv/src/type.ts
  • packages/arkenv/tsdown.config.ts
  • packages/bun-plugin/src/index.ts
  • packages/internal/scope/src/index.ts
  • packages/arkenv/package/README.md
  • packages/internal/keywords/package.json
  • packages/internal/scope/package.json
  • packages/internal/scope/tsdown.config.ts
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/package.json
  • packages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use ArkType's `type()` function to define schemas in environment variable definitions

Applied to files:

  • packages/arkenv/src/type.ts
  • packages/bun-plugin/src/index.ts
  • packages/internal/scope/src/index.ts
  • packages/arkenv/package/README.md
  • packages/internal/keywords/package.json
  • packages/internal/scope/package.json
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/package.json
  • packages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use union types for enums in ArkType schemas (e.g., `"'dev' | 'prod'"`) instead of separate enum definitions

Applied to files:

  • packages/arkenv/src/type.ts
  • packages/arkenv/tsdown.config.ts
  • packages/bun-plugin/src/index.ts
  • packages/internal/scope/src/index.ts
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/package.json
  • packages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's built-in types (e.g., `string.host`, `number.port`) where possible in environment schemas

Applied to files:

  • packages/arkenv/src/type.ts
  • packages/internal/keywords/src/index.test.ts
  • packages/bun-plugin/src/index.ts
  • packages/internal/scope/src/index.ts
  • packages/arkenv/package/README.md
  • packages/internal/keywords/package.json
  • packages/internal/scope/package.json
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/package.json
  • packages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Convert ArkType validation errors to `ArkEnvError` for user-friendly error messages that include variable name and expected type

Applied to files:

  • packages/arkenv/src/type.ts
  • packages/bun-plugin/src/index.ts
  • packages/arkenv/package/README.md
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/src/create-env.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to packages/arkenv/src/**/*.ts : Main library implementation should be in `src/create-env.ts`, built-in validators in `src/types.ts`, error handling in `src/errors.ts`, and utilities in `src/utils.ts`

Applied to files:

  • packages/arkenv/src/type.ts
  • packages/bun-plugin/src/index.ts
  • packages/arkenv/package/README.md
  • packages/internal/keywords/package.json
  • packages/internal/scope/package.json
  • packages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use PascalCase for type names (e.g., `ArkEnvError`)

Applied to files:

  • packages/arkenv/src/type.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use TypeScript 5.1+ features when appropriate

Applied to files:

  • packages/arkenv/tsdown.config.ts
  • packages/internal/scope/tsconfig.json
  • packages/internal/keywords/tsdown.config.ts
  • packages/internal/scope/tsdown.config.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use TypeScript for the primary language throughout the project

Applied to files:

  • packages/internal/scope/tsconfig.json
  • packages/internal/keywords/tsdown.config.ts
  • packages/internal/scope/tsdown.config.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Organize imports automatically (Biome handles this)

Applied to files:

  • packages/internal/scope/tsconfig.json
  • packages/internal/keywords/tsdown.config.ts
  • packages/internal/scope/tsdown.config.ts
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Applies to packages/*/package.json : Packages in packages/ directory must be published to npm and require changesets for versioning, proper exports, and type definitions

Applied to files:

  • packages/internal/scope/tsconfig.json
  • packages/internal/keywords/package.json
  • packages/internal/scope/package.json
  • packages/arkenv/package.json
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use JSDoc comments for public APIs

Applied to files:

  • packages/internal/scope/tsconfig.json
  • packages/internal/keywords/tsdown.config.ts
  • packages/internal/scope/tsdown.config.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use logical grouping for related environment variables in schemas

Applied to files:

  • packages/internal/scope/tsconfig.json
  • packages/bun-plugin/src/index.ts
  • packages/internal/scope/tsdown.config.ts
  • packages/vite-plugin/src/index.ts
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Applies to tooling/*/package.json : Tooling in tooling/ directory contains development and testing tools that are not published to npm and excluded from changesets

Applied to files:

  • packages/internal/scope/tsconfig.json
  • packages/internal/keywords/package.json
  • packages/internal/scope/package.json
  • pnpm-workspace.yaml
  • packages/arkenv/package.json
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Avoid explicit types when TypeScript can infer them (`noInferrableTypes` error)

Applied to files:

  • packages/internal/scope/tsconfig.json
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx,json,md} : Use Biome for linting and formatting instead of ESLint and Prettier

Applied to files:

  • packages/internal/scope/tsconfig.json
  • packages/internal/keywords/tsdown.config.ts
  • packages/internal/scope/tsdown.config.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.test.{ts,tsx} : Test edge cases including invalid and missing environment variable values

Applied to files:

  • packages/internal/keywords/src/index.test.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use built-in validators (host, port, url, email) from `src/types.ts` when available instead of custom validation

Applied to files:

  • packages/internal/keywords/src/index.test.ts
  • packages/internal/scope/src/index.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.integration.test.{ts,tsx} : Use integration tests with `*.integration.test.ts` or `*.integration.test.tsx` suffix to test how multiple units work together without mocking their interactions

Applied to files:

  • packages/internal/keywords/src/index.test.ts
📚 Learning: 2025-11-24T16:04:58.629Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:58.629Z
Learning: Applies to apps/playgrounds/bun/**/*.test.{ts,tsx,js,jsx} : Use `import { test, expect } from "bun:test"` for writing tests

Applied to files:

  • packages/internal/keywords/src/index.test.ts
📚 Learning: 2025-11-24T16:04:36.939Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-11-24T16:04:36.939Z
Learning: Applies to **/*.integration.test.{ts,tsx} : Test how multiple units (components, hooks, functions) work together without mocking their interactions in integration tests

Applied to files:

  • packages/internal/keywords/src/index.test.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.integration.test.{ts,tsx} : Integration tests should verify interactions between multiple units (like components + hooks + services) without mocking their interactions

Applied to files:

  • packages/internal/keywords/src/index.test.ts
📚 Learning: 2025-11-24T16:04:36.939Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-11-24T16:04:36.939Z
Learning: Applies to **/*.integration.test.{ts,tsx} : Use `*.integration.test.ts` suffix to distinguish integration tests from unit tests

Applied to files:

  • packages/internal/keywords/src/index.test.ts
📚 Learning: 2025-11-29T08:57:24.056Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: examples/with-bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-29T08:57:24.056Z
Learning: Applies to examples/with-bun-react/**/*.test.{ts,tsx,js,jsx} : Use test syntax from `bun:test` with `test` and `expect` functions

Applied to files:

  • packages/internal/keywords/src/index.test.ts
📚 Learning: 2025-11-24T16:04:47.583Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:47.583Z
Learning: Applies to apps/playgrounds/bun-react/**/*.test.{ts,tsx,js,jsx} : Use `bun:test` for unit and integration testing with `test` and `expect` from the built-in test module

Applied to files:

  • packages/internal/keywords/src/index.test.ts
📚 Learning: 2025-11-29T08:57:24.056Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: examples/with-bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-29T08:57:24.056Z
Learning: Applies to examples/with-bun-react/**/*.test.{ts,tsx,js,jsx} : Use `bun test` instead of `jest` or `vitest` for running tests

Applied to files:

  • packages/internal/keywords/src/index.test.ts
  • packages/internal/keywords/vitest.config.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Prefer `type` over `interface` for type definitions in TypeScript

Applied to files:

  • packages/internal/keywords/tsdown.config.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/index.ts : Use barrel exports (`index.ts`) for package entry points

Applied to files:

  • packages/internal/keywords/tsdown.config.ts
  • packages/internal/scope/tsdown.config.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use kebab-case for TypeScript filenames (e.g., `create-env.ts`)

Applied to files:

  • packages/internal/keywords/tsdown.config.ts
  • packages/internal/scope/tsdown.config.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use descriptive environment variable names that indicate purpose and format

Applied to files:

  • packages/internal/keywords/tsdown.config.ts
  • packages/internal/scope/tsdown.config.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use UPPER_SNAKE_CASE for environment variables and constants

Applied to files:

  • packages/internal/keywords/tsdown.config.ts
  • packages/internal/scope/tsdown.config.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use `createEnv(schema)` as the main function for validated environment objects, available as the default export

Applied to files:

  • packages/internal/keywords/tsdown.config.ts
  • packages/bun-plugin/src/index.ts
  • packages/internal/scope/tsdown.config.ts
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/src/create-env.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use `ArkEnvError` for environment variable errors, not generic errors

Applied to files:

  • packages/bun-plugin/src/index.ts
  • packages/arkenv/package/README.md
  • packages/internal/keywords/package.json
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use `ArkEnvError` for environment variable validation errors

Applied to files:

  • packages/bun-plugin/src/index.ts
  • packages/arkenv/package/README.md
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: ArkType validates environment variables at runtime and TypeScript types are inferred from the schema definition

Applied to files:

  • packages/bun-plugin/src/index.ts
  • packages/internal/scope/src/index.ts
  • packages/arkenv/package/README.md
  • packages/vite-plugin/src/index.ts
  • packages/arkenv/src/create-env.ts
📚 Learning: 2025-11-24T16:04:58.629Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:58.629Z
Learning: Applies to apps/playgrounds/bun/**/*.{ts,tsx,js,jsx} : Bun automatically loads .env files, so don't use `dotenv` library

Applied to files:

  • packages/bun-plugin/src/index.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/README.md : Document environment requirements in README files

Applied to files:

  • packages/arkenv/package/README.md
📚 Learning: 2025-09-10T19:35:18.179Z
Learnt from: yamcodes
Repo: yamcodes/arkenv PR: 136
File: .changeset/vast-bananas-win.md:2-3
Timestamp: 2025-09-10T19:35:18.179Z
Learning: The arkenv package is currently in v0.x.x (pre-1.0) development phase, where breaking changes are acceptable in minor version bumps according to semantic versioning conventions.

Applied to files:

  • packages/arkenv/package/README.md
📚 Learning: 2025-09-09T17:37:19.650Z
Learnt from: yamcodes
Repo: yamcodes/arkenv PR: 132
File: packages/arkenv/README.md:13-14
Timestamp: 2025-09-09T17:37:19.650Z
Learning: For yamcodes/arkenv project: Runtime support documentation should link to specific examples: Node.js (examples/basic), Bun (examples/with-bun), Vite (examples/with-vite-react-ts).

Applied to files:

  • packages/arkenv/package/README.md
📚 Learning: 2025-11-24T16:04:36.939Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-11-24T16:04:36.939Z
Learning: Achieve coverage goals: environment variable parsing and validation, type checking and error handling, default value handling, custom type validation, plugin integration with Vite, and real project build testing using examples as fixtures

Applied to files:

  • packages/arkenv/package/README.md
  • packages/internal/keywords/vitest.config.ts
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: Applies to **/package.json : Use workspace:* protocol for workspace dependencies between packages

Applied to files:

  • packages/internal/scope/package.json
  • packages/arkenv/package.json
📚 Learning: 2025-11-29T08:00:08.044Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/pnpm.mdc:0-0
Timestamp: 2025-11-29T08:00:08.044Z
Learning: Applies to {packages,apps,tooling}/**/package.json : When referencing workspace packages in dependencies, use the `workspace:*` protocol instead of version numbers

Applied to files:

  • packages/internal/scope/package.json
  • pnpm-workspace.yaml
  • packages/arkenv/package.json
📚 Learning: 2025-11-29T08:00:08.044Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/pnpm.mdc:0-0
Timestamp: 2025-11-29T08:00:08.044Z
Learning: Applies to package.json : The project uses `pnpm10.20.0` as specified in the `packageManager` field

Applied to files:

  • packages/internal/scope/package.json
📚 Learning: 2025-11-29T08:00:08.044Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/pnpm.mdc:0-0
Timestamp: 2025-11-29T08:00:08.044Z
Learning: Applies to package.json : Configure only built dependencies (native modules) in `pnpm.onlyBuiltDependencies`, including: biomejs/biome, sentry/cli, swc/core, tailwindcss/oxide, vercel/speed-insights, esbuild, and sharp

Applied to files:

  • packages/internal/scope/package.json
  • pnpm-workspace.yaml
  • packages/arkenv/package.json
📚 Learning: 2025-11-24T16:04:11.901Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/monorepo.mdc:0-0
Timestamp: 2025-11-24T16:04:11.901Z
Learning: packages/arkenv should not depend on other workspace packages; packages/vite-plugin depends on arkenv; apps/www may depend on workspace packages

Applied to files:

  • packages/internal/scope/package.json
  • pnpm-workspace.yaml
  • packages/arkenv/package.json
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Environment schema definitions should use built-in validators, ArkType string literals, and support default values in the schema pattern

Applied to files:

  • packages/vite-plugin/src/index.ts
  • packages/arkenv/src/create-env.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to pnpm-workspace.yaml : Use pnpm for package management with workspace support

Applied to files:

  • pnpm-workspace.yaml
  • packages/arkenv/package.json
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Always run `pnpm changeset` for version bumps in published packages - never skip changesets

Applied to files:

  • pnpm-workspace.yaml
📚 Learning: 2025-11-24T16:04:47.583Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:47.583Z
Learning: Applies to apps/playgrounds/bun-react/**/*.test.{ts,tsx,js,jsx} : Use `bun test` instead of `jest` or `vitest` for running tests

Applied to files:

  • pnpm-workspace.yaml
📚 Learning: 2025-11-24T16:04:47.583Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:47.583Z
Learning: Applies to apps/playgrounds/bun-react/**/*.html : Use HTML imports with `Bun.serve()` and don't use Vite for frontend bundling and development

Applied to files:

  • pnpm-workspace.yaml
📚 Learning: 2025-11-24T16:04:58.629Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:58.629Z
Learning: Applies to apps/playgrounds/bun/**/*.test.{ts,tsx,js,jsx} : Use `bun test` instead of `jest` or `vitest` for running tests

Applied to files:

  • pnpm-workspace.yaml
📚 Learning: 2025-11-24T16:04:47.583Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun-react/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:47.583Z
Learning: Applies to apps/playgrounds/bun-react/**/*.{ts,tsx,js,jsx,html,css} : Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild` for bundling

Applied to files:

  • pnpm-workspace.yaml
📚 Learning: 2025-11-24T16:04:36.939Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-11-24T16:04:36.939Z
Learning: Applies to tooling/playwright-www/**/*.spec.ts : Use Playwright for end-to-end tests

Applied to files:

  • pnpm-workspace.yaml
📚 Learning: 2025-11-24T16:04:58.629Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: apps/playgrounds/bun/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-11-24T16:04:58.629Z
Learning: Applies to apps/playgrounds/bun/**/*.{html,tsx,jsx} : Use HTML imports with `Bun.serve()` instead of Vite for frontend development

Applied to files:

  • pnpm-workspace.yaml
📚 Learning: 2025-11-24T16:04:36.939Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-11-24T16:04:36.939Z
Learning: Applies to tooling/playwright-www/**/*.spec.ts : Test complete user workflows and validate real browser behavior across Chromium, Firefox, and WebKit in end-to-end tests

Applied to files:

  • pnpm-workspace.yaml
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to tooling/playwright-www/**/*.{ts,tsx} : End-to-end tests should be located in `tooling/playwright-www/` and test complete user workflows in real browsers with no mocking

Applied to files:

  • pnpm-workspace.yaml
📚 Learning: 2025-11-24T16:04:36.939Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/test-patterns.mdc:0-0
Timestamp: 2025-11-24T16:04:36.939Z
Learning: Applies to **/*.test.{ts,tsx} : Test individual functions, components, and hooks in isolation with mocked dependencies in unit tests

Applied to files:

  • pnpm-workspace.yaml
🧬 Code graph analysis (3)
packages/vite-plugin/src/index.ts (4)
packages/arkenv/src/type.ts (1)
  • type (3-3)
packages/vite-plugin/src/types.ts (1)
  • ImportMetaEnvAugmented (56-59)
packages/internal/types/src/schema.ts (3)
  • EnvSchemaWithType (5-5)
  • SchemaShape (3-3)
  • SchemaShape (4-4)
packages/arkenv/src/create-env.ts (2)
  • EnvSchema (7-7)
  • createEnv (35-53)
packages/internal/keywords/turbo.json (1)
.github/actions/size-limit/src/config.ts (2)
  • Config (2-10)
  • Config (13-39)
packages/arkenv/src/create-env.ts (4)
packages/arkenv/src/index.ts (2)
  • EnvSchema (1-1)
  • createEnv (13-13)
packages/internal/scope/src/index.ts (1)
  • $ (9-19)
packages/internal/types/src/schema.ts (3)
  • EnvSchemaWithType (5-5)
  • SchemaShape (3-3)
  • SchemaShape (4-4)
packages/internal/types/src/infer-type.ts (1)
  • InferType (9-17)
🪛 LanguageTool
packages/arkenv/package/README.md

[style] ~129-~129: Using many exclamation marks might seem excessive (in this case: 5 exclamation marks for a text that’s 2639 characters long)
Context: ...the project by starring it on GitHub! You are also welcome to directly [cont...

(EN_EXCESSIVE_EXCLAMATION)

⏰ 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). (2)
  • GitHub Check: test-e2e (e2e)
  • GitHub Check: test-e2e (a11y)
🔇 Additional comments (21)
.gitignore (1)

45-46: LGTM!

Adding esbuild-generated debugging artifacts to .gitignore is a standard housekeeping practice that aligns with the PR's package config updates.

packages/internal/scope/turbo.json (1)

1-10: Per-package Turbo configuration is correct and consistent.

The configuration properly extends the root Turbo config using the ["//"] syntax and defines a locally-scoped size task. This pattern is consistently applied across packages/arkenv, packages/internal/keywords, and packages/internal/scope, with identical configurations. Disabling cache for the size task is appropriate for an analysis task, and the dependsOn: ["build"] dependency is correct. The explanatory comment accurately reflects the intent—defining the task per-package prevents unnecessary builds of all packages when running turbo run size.

packages/internal/scope/vitest.config.ts (1)

1-7: LGTM!

The Vitest configuration is correctly structured and follows the standard pattern for defining a project-specific test configuration. The test name "@repo/scope" properly identifies this internal package's tests within the monorepo.

packages/internal/keywords/vitest.config.ts (1)

1-7: LGTM!

The Vitest configuration is correctly structured and follows the same pattern as the scope package configuration. The test name "@repo/keywords" properly identifies this internal package's tests within the monorepo. Consistent configuration structure across internal packages aids maintainability.

pnpm-workspace.yaml (2)

8-30: Catalog formatting change: quote style normalization.

Lines 9–17 show quote style changes (double to single quotes) for consistency. This is purely cosmetic and aligns with maintainability best practices. No version changes or functional impact.


32-35: Overrides section reordering noted.

The overrides block has been reorganized (moved to the bottom of the file). The entries (@playwright/test, import-in-the-middle, require-in-the-middle) remain unchanged in content. This is a stylistic change with no functional impact on pnpm's resolution behavior.

packages/internal/keywords/src/index.test.ts (1)

2-2: LGTM!

The import path change from "./types" to "./index" follows the barrel export pattern, making the package's public API clearer and more maintainable.

packages/internal/keywords/turbo.json (1)

1-10: LGTM!

The per-package Turbo configuration correctly defines a size task with build dependency and disabled caching, preventing unnecessary package builds during size checks.

packages/arkenv/src/type.ts (1)

1-1: LGTM!

The import path change to "@repo/scope" aligns with the new internal package structure, improving modularity and maintainability.

packages/internal/scope/src/index.ts (1)

1-1: LGTM!

The import source change to "@repo/keywords" correctly uses the new internal package for built-in validators, maintaining separation of concerns.

Based on learnings: This follows ArkType's scoped type system pattern for defining custom types.

packages/internal/scope/tsconfig.json (1)

1-19: LGTM!

The TypeScript configuration correctly sets up strict compilation options with bundler module resolution, appropriate for an internal library package using tsdown for builds.

packages/arkenv/package.json (1)

43-44: Remove workspace package dependencies that violate architectural boundaries.

arkenv imports @repo/scope in src/type.ts and src/create-env.ts, making it a runtime dependency rather than just a dev tool. Since the architectural guidelines explicitly state that packages/arkenv should not depend on other workspace packages, these imports create coupling that violates the project's boundaries. The $ type system from @repo/scope is embedded into arkenv's public API through these imports.

Either:

  1. Move the necessary type definitions from @repo/scope directly into arkenv, or
  2. Establish an exception in the architectural rules if @repo/scope is intended as a shared internal utility

The @repo/keywords and @repo/types devDependencies should also be audited for similar coupling.

packages/arkenv/package/README.md (1)

1-133: Well-structured README with comprehensive documentation.

The README effectively covers:

  • Branding and ecosystem positioning
  • Clear code examples using ArkType syntax (aligning with project conventions)
  • Installation instructions for all major package managers
  • Requirements section with TypeScript and moduleResolution constraints
  • Links to plugins and further documentation

The static analysis hint about exclamation marks is a false positive for README marketing content—the tone is appropriate for engaging documentation.

packages/vite-plugin/src/index.ts (2)

60-66: Overload structure correctly handles both schema types.

The overload ordering (specific EnvSchemaWithType first, then generic EnvSchema<T>) follows TypeScript best practices for function overloading, ensuring proper type inference for both use cases.


76-84: Type assertions documented as workaround—acceptable interim solution.

The explicit createEnv<T> call and <SchemaShape>env cast are documented via the TODO comment as workarounds for "excessively deep" instantiation errors. This is a reasonable approach while maintaining runtime correctness. Consider tracking this as technical debt to revisit when ArkType/TypeScript provides better inference.

packages/bun-plugin/src/index.ts (3)

12-21: Generic constraint and TODO documentation align with vite-plugin pattern.

The processEnvSchema<T extends SchemaShape> signature and the documented workaround for deep instantiation errors are consistent with the vite-plugin implementation, ensuring uniform behavior across plugins.


89-92: Empty catch block intentionally ignores file read errors.

The catch {} without an error variable correctly follows the existing behavior of returning undefined to let Bun handle unreadable files. This is a valid pattern per recent TypeScript/JavaScript support for empty catch bindings.


127-134: Overloads correctly mirror vite-plugin structure.

The three-signature pattern (EnvSchemaWithType, EnvSchema<T>, implementation) maintains API consistency across the plugin ecosystem.

packages/arkenv/src/create-env.ts (3)

1-7: Clean import reorganization with proper type separation.

The imports are well-organized:

  • Internal scope from @repo/scope
  • Public types from @repo/types
  • ArkType utilities as at namespace alias (avoiding collision with local type)
  • Local type from ./type for error checking

The EnvSchema<def> type alias correctly uses at.validate for compile-time schema validation against the scoped type system.


23-38: Overload structure provides comprehensive type inference.

The four signatures handle:

  1. EnvSchemaWithType (pre-defined ArkType) → InferType<T>
  2. EnvSchema<T> (raw schema object) → distill.Out<at.infer<T, ...>>
  3. Union type for flexibility
  4. Implementation with default env = process.env

This pattern enables type-safe usage for both raw schema objects and pre-constructed ArkType definitions, aligning with the PR objective to improve input types.


39-52: Runtime validation logic correctly preserved.

The implementation:

  • Detects ArkType definitions via typeof def === "function" && "assert" in def
  • Falls back to $.type.raw() for raw schema objects
  • Throws ArkEnvError on validation failures (per coding guidelines)

This maintains backward compatibility while supporting the new overloaded signatures.

@yamcodes yamcodes changed the title Improve core input types Overhaul internal structure and improve typesafety Dec 8, 2025
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

♻️ Duplicate comments (1)
packages/arkenv/src/create-env.test.ts (1)

169-173: Avoid as never here; it defeats the improved typing.

Env is already the result of type({ INVALID_PORT: "number.port" }) and should be assignable to the EnvSchemaWithType branch of createEnv. Casting it to never bypasses the very type guarantees this PR is adding and mirrors the earlier concern about heavy casts.

Please try removing the cast and fixing types at the createEnv/EnvSchemaWithType level if needed instead of escaping with as never:

-			expect(() => createEnv(Env as never)).toThrow(/INVALID_PORT/);
+			expect(() => createEnv(Env)).toThrow(/INVALID_PORT/);

If this still doesn’t type‑check, it’s a strong signal the generics around SchemaShape / EnvSchemaWithType need a small adjustment rather than a cast.

🧹 Nitpick comments (1)
packages/internal/types/src/schema.ts (1)

1-6: Clarify value vs type alias naming for SchemaShape.

You export both a value and a type alias named SchemaShape. TypeScript allows this, but it’s easy to misread which one is being referenced. If the runtime SchemaShape instance is only used to derive the alias, consider either not exporting it or renaming one of them (e.g. SchemaShapeType for the type alias or schemaShapeType for the value) to keep the intent obvious.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4993d8b and 70193a4.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • packages/arkenv/src/create-env.test.ts (5 hunks)
  • packages/internal/types/package.json (1 hunks)
  • packages/internal/types/src/schema.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/internal/types/package.json
🧰 Additional context used
📓 Path-based instructions (5)
packages/arkenv/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/arktype.mdc)

packages/arkenv/**/*.ts: Use ArkType's type() function to define schemas in environment variable definitions
Leverage ArkType's type inference for TypeScript types instead of manual type definitions
Use the scoped $ type system for custom types defined in scope.ts
Keep environment variable schemas readable and TypeScript-like using ArkType syntax
Use union types for enums in ArkType schemas (e.g., "'dev' | 'prod'") instead of separate enum definitions
Leverage ArkType's built-in types (e.g., string.host, number.port) where possible in environment schemas
Convert ArkType validation errors to ArkEnvError for user-friendly error messages that include variable name and expected type

Files:

  • packages/arkenv/src/create-env.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

**/*.{ts,tsx}: Prefer type over interface for type definitions in TypeScript
Use TypeScript 5.1+ features when appropriate
Leverage const type parameters for better inference in TypeScript
Use JSDoc comments for public APIs
Use tabs for indentation (configured in Biome)
Use double quotes for strings (configured in Biome)
Organize imports automatically (Biome handles this)
Avoid explicit types when TypeScript can infer them (noInferrableTypes error)
Use as const where appropriate for immutable values (useAsConstAssertion error)
Don't reassign function parameters (noParameterAssign error)
Place default parameters last in function signatures (useDefaultParameterLast error)
Always initialize enum values (useEnumInitializers error)
Declare one variable per statement (useSingleVarDeclarator error)
Avoid unnecessary template literals (noUnusedTemplateLiteral error)
Prefer Number.parseInt over global parseInt (useNumberNamespace error)
Use kebab-case for TypeScript filenames (e.g., create-env.ts)
Use camelCase for function names (e.g., createEnv)
Use PascalCase for type names (e.g., ArkEnvError)
Use UPPER_SNAKE_CASE for environment variables and constants
Include examples in JSDoc comments when helpful for public APIs
Document complex type logic with JSDoc comments
Use ArkEnvError for environment variable validation errors
Provide clear, actionable error messages that include the variable name and expected type

**/*.{ts,tsx}: Use createEnv(schema) as the main function for validated environment objects, available as the default export
Use built-in validators (host, port, url, email) from src/types.ts when available instead of custom validation
Use ArkEnvError for environment variable errors, not generic errors
Environment schema definitions should use built-in validators, ArkType string literals, and support default values in the schema pattern
Use logical grouping for related environment variables in schemas
Use descriptive env...

Files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/coding-guidelines.mdc)

Co-locate tests with components: Component.tsx next to Component.test.tsx

**/*.test.{ts,tsx}: Test individual functions, components, and hooks in isolation with mocked dependencies in unit tests
Keep unit tests fast with execution under 100ms per test
Co-locate unit tests with source files using naming convention: source.tssource.test.ts
Focus component tests on public API, user behavior, state transitions, and accessibility rather than styling or implementation details
Query component tests by role, name, label, and text using accessibility-first selectors
Use Vitest as the test framework for unit and integration tests
Use Testing Library with user-event for real user simulation in component tests

**/*.test.{ts,tsx}: Test individual functions, components, and hooks in isolation with mocked dependencies using the *.test.ts or *.test.tsx suffix
Mock process.env in tests for different scenarios and save/restore original env in beforeEach/afterEach hooks
Use Vitest's describe/it structure in test files
Test edge cases including invalid and missing environment variable values
Use Vitest for testing framework

Files:

  • packages/arkenv/src/create-env.test.ts
packages/arkenv/src/**/*.ts

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Main library implementation should be in src/create-env.ts, built-in validators in src/types.ts, error handling in src/errors.ts, and utilities in src/utils.ts

Files:

  • packages/arkenv/src/create-env.test.ts
**/*.{ts,tsx,json,md}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use Biome for linting and formatting instead of ESLint and Prettier

Files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
🧠 Learnings (23)
📓 Common learnings
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Keep environment variable schemas readable and TypeScript-like using ArkType syntax
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's built-in types (e.g., `string.host`, `number.port`) where possible in environment schemas
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's type inference for TypeScript types instead of manual type definitions
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/scope.ts : Define custom types in `scope.ts` using ArkType's scoped type system for reusability across schemas
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use union types for enums in ArkType schemas (e.g., `"'dev' | 'prod'"`) instead of separate enum definitions
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use ArkType's `type()` function to define schemas in environment variable definitions
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: ArkType validates environment variables at runtime and TypeScript types are inferred from the schema definition
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Convert ArkType validation errors to `ArkEnvError` for user-friendly error messages that include variable name and expected type
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use the scoped `$` type system for custom types defined in `scope.ts`
Learnt from: yamcodes
Repo: yamcodes/arkenv PR: 498
File: apps/playgrounds/node/index.ts:2-2
Timestamp: 2025-12-05T20:33:10.676Z
Learning: ArkType 2.1.28+ supports Standard Schema specification, allowing interoperability with other Standard Schema-compliant validation libraries (e.g., Zod, Valibot) within the same schema definition
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Keep environment variable schemas readable and TypeScript-like using ArkType syntax

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's built-in types (e.g., `string.host`, `number.port`) where possible in environment schemas

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use `createEnv(schema)` as the main function for validated environment objects, available as the default export

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use ArkType's `type()` function to define schemas in environment variable definitions

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Convert ArkType validation errors to `ArkEnvError` for user-friendly error messages that include variable name and expected type

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use union types for enums in ArkType schemas (e.g., `"'dev' | 'prod'"`) instead of separate enum definitions

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.test.{ts,tsx} : Mock `process.env` in tests for different scenarios and save/restore original env in `beforeEach`/`afterEach` hooks

Applied to files:

  • packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to packages/arkenv/src/**/*.ts : Main library implementation should be in `src/create-env.ts`, built-in validators in `src/types.ts`, error handling in `src/errors.ts`, and utilities in `src/utils.ts`

Applied to files:

  • packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Environment schema definitions should use built-in validators, ArkType string literals, and support default values in the schema pattern

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Leverage ArkType's type inference for TypeScript types instead of manual type definitions

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use `as const` where appropriate for immutable values (`useAsConstAssertion` error)

Applied to files:

  • packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Avoid explicit types when TypeScript can infer them (`noInferrableTypes` error)

Applied to files:

  • packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use descriptive environment variable names that indicate purpose and format

Applied to files:

  • packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Leverage `const` type parameters for better inference in TypeScript

Applied to files:

  • packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.test.{ts,tsx} : Test edge cases including invalid and missing environment variable values

Applied to files:

  • packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Provide clear, actionable error messages that include the variable name and expected type

Applied to files:

  • packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Avoid unnecessary template literals (`noUnusedTemplateLiteral` error)

Applied to files:

  • packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: ArkType validates environment variables at runtime and TypeScript types are inferred from the schema definition

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
📚 Learning: 2025-11-29T22:11:39.931Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T22:11:39.931Z
Learning: Applies to **/*.{ts,tsx} : Use logical grouping for related environment variables in schemas

Applied to files:

  • packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-24T16:04:00.957Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/coding-guidelines.mdc:0-0
Timestamp: 2025-11-24T16:04:00.957Z
Learning: Applies to **/*.{ts,tsx} : Use `ArkEnvError` for environment variable validation errors

Applied to files:

  • packages/arkenv/src/create-env.test.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/scope.ts : Define custom types in `scope.ts` using ArkType's scoped type system for reusability across schemas

Applied to files:

  • packages/arkenv/src/create-env.test.ts
  • packages/internal/types/src/schema.ts
📚 Learning: 2025-11-24T16:03:45.295Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .cursor/rules/arktype.mdc:0-0
Timestamp: 2025-11-24T16:03:45.295Z
Learning: Applies to packages/arkenv/**/*.ts : Use the scoped `$` type system for custom types defined in `scope.ts`

Applied to files:

  • packages/internal/types/src/schema.ts
🧬 Code graph analysis (2)
packages/arkenv/src/create-env.test.ts (3)
packages/arkenv/src/type.ts (1)
  • type (3-3)
packages/arkenv/src/create-env.ts (1)
  • createEnv (35-53)
packages/arkenv/src/index.ts (1)
  • createEnv (13-13)
packages/internal/types/src/schema.ts (2)
packages/arkenv/src/type.ts (1)
  • type (3-3)
packages/internal/scope/src/index.ts (1)
  • $ (9-19)
⏰ 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: test-e2e (e2e)
  • GitHub Check: test-e2e (a11y)
  • GitHub Check: test-build (lts/*)
🔇 Additional comments (4)
packages/arkenv/src/create-env.test.ts (4)

117-123: Good switch to passing ArkType type() definitions directly.

Defining const Env = type({ ... }) and calling createEnv(Env) exercises the new EnvSchemaWithType path and keeps tests aligned with the public API.


132-141: Letting TypeScript infer env member types is preferable here.

Reusing Env = type({ ... }) and then assigning const str = env.TEST_STRING; const port = env.TEST_PORT; without explicit annotations ensures the test actually relies on the new type inference instead of duplicating types manually, which matches the “avoid inferrable types” guideline.


150-160: Nice coverage for reusing a single Env definition.

Using the same Env type definition with different custom env objects (env1, env2) is a solid regression test for the “define once, reuse everywhere” story around type() output. No issues spotted.


177-188: Custom env + type() definitions test looks solid.

This case nicely validates that createEnv works with ArkType Env definitions and a custom env object (including parsing "8080" into a number.port). The scenario is representative of real plugin usage; no changes needed.

@github-actions github-actions bot added the github actions Pull requests that update GitHub Actions code label Dec 8, 2025
@yamcodes yamcodes merged commit 0a44dcd into main Dec 8, 2025
19 checks passed
@yamcodes yamcodes deleted the 501-improve-input-types branch December 8, 2025 20:37
@arkenv-bot arkenv-bot bot mentioned this pull request Dec 8, 2025
yamcodes pushed a commit that referenced this pull request Dec 8, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @arkenv/bun-plugin@0.0.2

### Patch Changes

- #### Fix "Type instantiation is excessively deep" error
_[`#511`](#511)
[`0a44dcd`](0a44dcd)
[@yamcodes](https://github.com/yamcodes)_

Fixed "Type instantiation is excessively deep and possibly infinite"
errors when using the plugins with complex ArkType schemas. This was
[reported](#497) in the ArkEnv
Vite Plugin along with [ArkType
2.1.28](https://github.com/arktypeio/arktype/blob/HEAD/ark/type/CHANGELOG.md#2128),
and was fixed by an overall improvement of type stability including
optimizing how generics are passed to the validation logic.

<details><summary>Updated 1 dependency</summary>

<small>

</small>

-   `arkenv@0.7.6`

</details>

## @arkenv/vite-plugin@0.0.19

### Patch Changes

- #### Fix "Type instantiation is excessively deep" error
_[`#511`](#511)
[`0a44dcd`](0a44dcd)
[@yamcodes](https://github.com/yamcodes)_

Fixed "Type instantiation is excessively deep and possibly infinite"
errors when using the plugins with complex ArkType schemas. This was
[reported](#497) in the ArkEnv
Vite Plugin along with [ArkType
2.1.28](https://github.com/arktypeio/arktype/blob/HEAD/ark/type/CHANGELOG.md#2128),
and was fixed by an overall improvement of type stability including
optimizing how generics are passed to the validation logic.

<details><summary>Updated 1 dependency</summary>

<small>

</small>

-   `arkenv@0.7.6`

</details>

## @repo/types@0.0.1

### Patch Changes

- #### Add Schema types
_[`#511`](#511)
[`0a44dcd`](0a44dcd)
[@yamcodes](https://github.com/yamcodes)_

Add Schema types to internal types package, including
`EnvSchemaWithType` and `SchemaShape`.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

@arkenv/vite-plugin Issues or Pull Requests involving the Vite plugin for ArkEnv arkenv Changes to the `arkenv` npm package. docs Improvements or additions to documentation github actions Pull requests that update GitHub Actions code tests This issue or PR is about adding, removing or changing tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve input types

1 participant