UEA-Prodem

This commit is contained in:
2026-06-10 12:38:42 -03:00
parent 3f33154e16
commit c41625e542
9352 changed files with 1128292 additions and 14752 deletions
+22
View File
@@ -0,0 +1,22 @@
MIT License
Copyright (c) Pooya Parsa <pooya@pi0.io>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+91
View File
@@ -0,0 +1,91 @@
# std-env
[![npm version](https://img.shields.io/npm/v/std-env.svg?style=flat-square)](http://npmjs.com/package/std-env)
[![npm downloads](https://img.shields.io/npm/dm/std-env.svg?style=flat-square)](http://npmjs.com/package/std-env)
[![bundle size](https://img.shields.io/bundlephobia/min/std-env/latest.svg?style=flat-square)](https://bundlephobia.com/result?p=std-env)
Runtime-agnostic JS utils for detecting environments, runtimes, CI providers, and AI coding agents.
## Runtime Detection
Detects the current JavaScript runtime based on global variables, following the [WinterCG Runtime Keys proposal](https://runtime-keys.proposal.wintercg.org/).
```ts
import { runtime, runtimeInfo } from "std-env";
console.log(runtime); // "" | "node" | "deno" | "bun" | "workerd" ...
console.log(runtimeInfo); // { name: "node" }
```
Individual named exports: `isNode`, `isBun`, `isDeno`, `isNetlify`, `isEdgeLight`, `isWorkerd`, `isFastly`
> [!NOTE]
> `isNode` is also `true` in Bun/Deno with Node.js compatibility mode. Use `runtime === "node"` for strict checks.
See [./src/runtimes.ts](./src/runtimes.ts) for the full list.
## Provider Detection
Detects the current CI/CD provider based on environment variables.
```ts
import { isCI, provider, providerInfo } from "std-env";
console.log({ isCI, provider, providerInfo });
// { isCI: true, provider: "github_actions", providerInfo: { name: "github_actions", ci: true } }
```
Use `detectProvider()` to re-run detection. See [./src/providers.ts](./src/providers.ts) for the full list.
## Agent Detection
Detects if the environment is running inside an AI coding agent.
```ts
import { isAgent, agent, agentInfo } from "std-env";
console.log({ isAgent, agent, agentInfo });
// { isAgent: true, agent: "claude", agentInfo: { name: "claude" } }
```
Set the `AI_AGENT` env var to explicitly specify the agent name. Use `detectAgent()` to re-run detection.
Supported agents: `cursor`, `claude`, `devin`, `replit`, `gemini`, `codex`, `auggie`, `opencode`, `kiro`, `goose`, `pi`
## Flags
```js
import { env, isDevelopment, isProduction } from "std-env";
```
| Export | Description |
| ------------------ | ------------------------------------------------------------ |
| `hasTTY` | stdout TTY is available |
| `hasWindow` | Global `window` is available |
| `isCI` | Running in CI |
| `isColorSupported` | Terminal color output supported |
| `isDebug` | `DEBUG` env var is set |
| `isDevelopment` | `NODE_ENV` is `dev`/`development` or `MODE` is `development` |
| `isLinux` | Linux platform |
| `isMacOS` | macOS (darwin) platform |
| `isMinimal` | `MINIMAL` env is set, CI, test, or no TTY |
| `isProduction` | `NODE_ENV` or `MODE` is `production` |
| `isTest` | `NODE_ENV` is `test` or `TEST` env is set |
| `isWindows` | Windows platform |
| `platform` | Value of `process.platform` |
| `nodeVersion` | Node.js version string (e.g. `"22.0.0"`) |
| `nodeMajorVersion` | Node.js major version number (e.g. `22`) |
See [./src/flags.ts](./src/flags.ts) for details.
## Environment
| Export | Description |
| --------- | ---------------------------------------------------- |
| `env` | Universal `process.env` (works across all runtimes) |
| `process` | Universal `process` shim (works across all runtimes) |
| `nodeENV` | Current `NODE_ENV` value (undefined if unset) |
## License
MIT
+182
View File
@@ -0,0 +1,182 @@
//#region src/agents.d.ts
/**
* Represents the name of an AI coding agent.
*/
type AgentName = (string & {}) | "cursor" | "claude" | "devin" | "replit" | "gemini" | "codex" | "auggie" | "opencode" | "kiro" | "goose" | "pi";
/**
* Provides information about an AI coding agent.
*/
type AgentInfo = {
/**
* The name of the AI coding agent. See {@link AgentName} for possible values.
*/
name?: AgentName;
};
/**
* Detects the current AI coding agent from environment variables.
*
* Supported agents: `cursor`, `claude`, `devin`, `replit`, `gemini`, `codex`, `auggie`, `opencode`, `kiro`, `goose`, `pi`
*
* You can also set the `AI_AGENT` environment variable to explicitly specify the agent name.
*/
declare function detectAgent(): AgentInfo;
/**
* The detected agent information for the current execution context.
* This value is evaluated once at module initialisation.
*/
declare const agentInfo: AgentInfo;
/**
* Name of the detected agent.
*/
declare const agent: AgentName | undefined;
/**
* A boolean flag indicating whether the current environment is running inside an AI coding agent.
*/
declare const isAgent: boolean;
//#endregion
//#region src/env.d.ts
/**
* Runtime-agnostic reference to environment variables.
*
* Resolves to `globalThis.process.env` when available, otherwise an empty object.
*/
declare const env: Record<string, string | undefined>;
/**
* Runtime-agnostic reference to the `process` global.
*
* Resolves to `globalThis.process` when available, otherwise a minimal shim containing only `env`.
*/
declare const process: Partial<typeof globalThis.process>;
/**
* Current value of the `NODE_ENV` environment variable (or static value if replaced during build).
*
* If `NODE_ENV` is not set, this will be undefined.
*/
declare const nodeENV: string | undefined;
//#endregion
//#region src/flags.d.ts
/** Value of process.platform */
declare const platform: string;
/** Detect if `CI` environment variable is set or a provider CI detected */
declare const isCI: boolean;
/** Detect if stdout.TTY is available */
declare const hasTTY: boolean;
/** Detect if global `window` object is available */
declare const hasWindow: boolean;
/** Detect if `DEBUG` environment variable is set */
declare const isDebug: boolean;
/** Detect if `NODE_ENV` environment variable is `test` or `TEST` environment variable is set */
declare const isTest: boolean;
/** Detect if `NODE_ENV` or `MODE` environment variable is `production` */
declare const isProduction: boolean;
/** Detect if `NODE_ENV` environment variable is `dev` or `development`, or if `MODE` environment variable is `development` */
declare const isDevelopment: boolean;
/** Detect if MINIMAL environment variable is set, running in CI or test or TTY is unavailable */
declare const isMinimal: boolean;
/** Detect if process.platform is Windows */
declare const isWindows: boolean;
/** Detect if process.platform is Linux */
declare const isLinux: boolean;
/** Detect if process.platform is macOS (darwin kernel) */
declare const isMacOS: boolean;
/** Detect if terminal color output is supported based on `NO_COLOR`, `FORCE_COLOR`, TTY, and CI environment */
declare const isColorSupported: boolean;
/** Node.js version string (e.g. `"20.11.0"`), or `null` if not running in Node.js */
declare const nodeVersion: string | null;
/** Node.js major version number (e.g. `20`), or `null` if not running in Node.js */
declare const nodeMajorVersion: number | null;
//#endregion
//#region src/providers.d.ts
/**
* Represents the name of a CI/CD or Deployment provider.
*/
type ProviderName = (string & {}) | "appveyor" | "aws_amplify" | "azure_pipelines" | "azure_static" | "appcircle" | "bamboo" | "bitbucket" | "bitrise" | "buddy" | "buildkite" | "circle" | "cirrus" | "cloudflare_pages" | "cloudflare_workers" | "google_cloudrun" | "google_cloudrun_job" | "codebuild" | "codefresh" | "drone" | "drone" | "dsari" | "github_actions" | "gitlab" | "gocd" | "layerci" | "hudson" | "jenkins" | "magnum" | "netlify" | "nevercode" | "render" | "sail" | "semaphore" | "screwdriver" | "shippable" | "solano" | "strider" | "teamcity" | "travis" | "vercel" | "appcenter" | "codesandbox" | "stackblitz" | "stormkit" | "cleavr" | "zeabur" | "codesphere" | "railway" | "deno-deploy" | "firebase_app_hosting" | "edgeone_pages";
/**
* Provides information about a CI/CD or Deployment provider, including its name and possibly other metadata.
*/
type ProviderInfo = {
/**
* The name of the CI/CD or Deployment provider. See {@link ProviderName} for possible values.
*/
name: ProviderName;
/**
* If is set to `true`, the environment is recognised as a CI/CD provider.
*/
ci?: boolean;
/**
* Arbitrary metadata associated with the provider.
*/
[meta: string]: any;
};
/**
* Detects the current CI/CD or Deployment provider from environment variables.
*/
declare function detectProvider(): ProviderInfo;
/**
* The detected provider information for the current execution context.
* This value is evaluated once at module initialisation.
*/
declare const providerInfo: ProviderInfo;
/**
* Name of the detected provider, defaults to an empty string if no provider is detected.
*/
declare const provider: ProviderName;
//#endregion
//#region src/runtimes.d.ts
/**
* Represents the name of a JavaScript runtime.
*
* @see https://runtime-keys.proposal.wintercg.org/
*/
type RuntimeName = (string & {}) | "workerd" | "deno" | "netlify" | "node" | "bun" | "edge-light" | "fastly";
type RuntimeInfo = {
/**
* The name of the detected runtime.
*/
name: RuntimeName;
};
/**
* Indicates if running in Node.js or a Node.js compatible runtime.
*
* **Note:** When running code in Bun and Deno with Node.js compatibility mode, `isNode` flag will be also `true`, indicating running in a Node.js compatible runtime.
*
* Use `runtime === "node"` if you need strict check for Node.js runtime.
*/
declare const isNode: boolean;
/**
* Indicates if running in Bun runtime.
*/
declare const isBun: boolean;
/**
* Indicates if running in Deno runtime.
*/
declare const isDeno: boolean;
/**
* Indicates if running in Fastly runtime.
*/
declare const isFastly: boolean;
/**
* Indicates if running in Netlify runtime.
*/
declare const isNetlify: boolean;
/**
* Indicates if running in EdgeLight (Vercel Edge) runtime.
*/
declare const isEdgeLight: boolean;
/**
* Indicates if running in Cloudflare Workers runtime.
*
* https://developers.cloudflare.com/workers/runtime-apis/web-standards/#navigatoruseragent
*/
declare const isWorkerd: boolean;
/**
* Contains information about the detected runtime, if any.
*/
declare const runtimeInfo: RuntimeInfo | undefined;
/**
* A convenience constant that returns the name of the detected runtime,
* defaults to an empty string if no runtime is detected.
*/
declare const runtime: RuntimeName;
//#endregion
export { type AgentInfo, type AgentName, type ProviderInfo, type ProviderName, type RuntimeInfo, type RuntimeName, agent, agentInfo, detectAgent, detectProvider, env, hasTTY, hasWindow, isAgent, isBun, isCI, isColorSupported, isDebug, isDeno, isDevelopment, isEdgeLight, isFastly, isLinux, isMacOS, isMinimal, isNetlify, isNode, isProduction, isTest, isWindows, isWorkerd, nodeENV, nodeMajorVersion, nodeVersion, platform, process, provider, providerInfo, runtime, runtimeInfo };
+1
View File
@@ -0,0 +1 @@
const e=globalThis.process?.env||Object.create(null),t=globalThis.process||{env:e},n=t!==void 0&&t.env&&t.env.NODE_ENV||void 0,r=[[`claude`,[`CLAUDECODE`,`CLAUDE_CODE`]],[`replit`,[`REPL_ID`]],[`gemini`,[`GEMINI_CLI`]],[`codex`,[`CODEX_SANDBOX`,`CODEX_THREAD_ID`]],[`opencode`,[`OPENCODE`]],[`pi`,[i(`PATH`,/\.pi[\\/]agent/)]],[`auggie`,[`AUGMENT_AGENT`]],[`goose`,[`GOOSE_PROVIDER`]],[`devin`,[i(`EDITOR`,/devin/)]],[`cursor`,[`CURSOR_AGENT`]],[`kiro`,[i(`TERM_PROGRAM`,/kiro/)]]];function i(t,n){return()=>{let r=e[t];return r?n.test(r):!1}}function a(){let t=e.AI_AGENT;if(t)return{name:t.toLowerCase()};for(let[t,n]of r)for(let r of n)if(typeof r==`string`?e[r]:r())return{name:t};return{}}const o=a(),s=o.name,c=!!o.name,l=[[`APPVEYOR`],[`AWS_AMPLIFY`,`AWS_APP_ID`,{ci:!0}],[`AZURE_PIPELINES`,`SYSTEM_TEAMFOUNDATIONCOLLECTIONURI`],[`AZURE_STATIC`,`INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN`],[`APPCIRCLE`,`AC_APPCIRCLE`],[`BAMBOO`,`bamboo_planKey`],[`BITBUCKET`,`BITBUCKET_COMMIT`],[`BITRISE`,`BITRISE_IO`],[`BUDDY`,`BUDDY_WORKSPACE_ID`],[`BUILDKITE`],[`CIRCLE`,`CIRCLECI`],[`CIRRUS`,`CIRRUS_CI`],[`CLOUDFLARE_PAGES`,`CF_PAGES`,{ci:!0}],[`CLOUDFLARE_WORKERS`,`WORKERS_CI`,{ci:!0}],[`GOOGLE_CLOUDRUN`,`K_SERVICE`],[`GOOGLE_CLOUDRUN_JOB`,`CLOUD_RUN_JOB`],[`CODEBUILD`,`CODEBUILD_BUILD_ARN`],[`CODEFRESH`,`CF_BUILD_ID`],[`DRONE`],[`DRONE`,`DRONE_BUILD_EVENT`],[`DSARI`],[`GITHUB_ACTIONS`],[`GITLAB`,`GITLAB_CI`],[`GITLAB`,`CI_MERGE_REQUEST_ID`],[`GOCD`,`GO_PIPELINE_LABEL`],[`LAYERCI`],[`JENKINS`,`JENKINS_URL`],[`HUDSON`,`HUDSON_URL`],[`MAGNUM`],[`NETLIFY`],[`NETLIFY`,`NETLIFY_LOCAL`,{ci:!1}],[`NEVERCODE`],[`RENDER`],[`SAIL`,`SAILCI`],[`SEMAPHORE`],[`SCREWDRIVER`],[`SHIPPABLE`],[`SOLANO`,`TDDIUM`],[`STRIDER`],[`TEAMCITY`,`TEAMCITY_VERSION`],[`TRAVIS`],[`VERCEL`,`NOW_BUILDER`],[`VERCEL`,`VERCEL`,{ci:!1}],[`VERCEL`,`VERCEL_ENV`,{ci:!1}],[`APPCENTER`,`APPCENTER_BUILD_ID`],[`CODESANDBOX`,`CODESANDBOX_SSE`,{ci:!1}],[`CODESANDBOX`,`CODESANDBOX_HOST`,{ci:!1}],[`STACKBLITZ`],[`STORMKIT`],[`CLEAVR`],[`ZEABUR`],[`CODESPHERE`,`CODESPHERE_APP_ID`,{ci:!0}],[`RAILWAY`,`RAILWAY_PROJECT_ID`],[`RAILWAY`,`RAILWAY_SERVICE_ID`],[`DENO-DEPLOY`,`DENO_DEPLOY`],[`DENO-DEPLOY`,`DENO_DEPLOYMENT_ID`],[`FIREBASE_APP_HOSTING`,`FIREBASE_APP_HOSTING`,{ci:!0}],[`EDGEONE_PAGES`,`EO_PAGES_CI`,{ci:!0}]];function u(){for(let t of l)if(e[t[1]||t[0]])return{name:t[0].toLowerCase(),...t[2]};return e.SHELL===`/bin/jsh`&&t.versions?.webcontainer?{name:`stackblitz`,ci:!1}:{name:``,ci:!1}}const d=u(),f=d.name,p=t.platform||``,m=!!e.CI||d.ci!==!1,h=!!t.stdout?.isTTY,g=typeof window<`u`,_=!!e.DEBUG,v=n===`test`||!!e.TEST,y=n===`production`||e.MODE===`production`,b=n===`dev`||n===`development`||e.MODE===`development`,x=!!e.MINIMAL||m||v||!h,S=/^win/i.test(p),C=/^linux/i.test(p),w=/^darwin/i.test(p),T=!e.NO_COLOR&&(!!e.FORCE_COLOR||(h||S)&&e.TERM!==`dumb`||m),E=(t.versions?.node||``).replace(/^v/,``)||null,D=Number(E?.split(`.`)[0])||null,O=!!t?.versions?.node,k=`Bun`in globalThis,A=`Deno`in globalThis,j=`fastly`in globalThis,M=`Netlify`in globalThis,N=`EdgeRuntime`in globalThis,P=globalThis.navigator?.userAgent===`Cloudflare-Workers`,F=[[M,`netlify`],[N,`edge-light`],[P,`workerd`],[j,`fastly`],[A,`deno`],[k,`bun`],[O,`node`]];function I(){let e=F.find(e=>e[0]);if(e)return{name:e[1]}}const L=I(),R=L?.name||``;export{s as agent,o as agentInfo,a as detectAgent,u as detectProvider,e as env,h as hasTTY,g as hasWindow,c as isAgent,k as isBun,m as isCI,T as isColorSupported,_ as isDebug,A as isDeno,b as isDevelopment,N as isEdgeLight,j as isFastly,C as isLinux,w as isMacOS,x as isMinimal,M as isNetlify,O as isNode,y as isProduction,v as isTest,S as isWindows,P as isWorkerd,n as nodeENV,D as nodeMajorVersion,E as nodeVersion,p as platform,t as process,f as provider,d as providerInfo,R as runtime,L as runtimeInfo};
+42
View File
@@ -0,0 +1,42 @@
{
"name": "std-env",
"version": "4.1.0",
"description": "Runtime agnostic JS utils",
"license": "MIT",
"repository": "unjs/std-env",
"files": [
"dist"
],
"type": "module",
"sideEffects": false,
"main": "./dist/index.mjs",
"types": "./dist/index.d.mts",
"exports": {
".": "./dist/index.mjs"
},
"scripts": {
"build": "obuild",
"dev": "vitest",
"lint": "oxlint . && oxfmt",
"lint:fix": "oxlint --fix . && oxfmt",
"prepack": "obuild",
"release": "pnpm test && pnpm build && changelogen --release --publish && git push --follow-tags",
"test": "pnpm lint && pnpm typecheck && vitest run --coverage",
"typecheck": "tsgo --noEmit"
},
"devDependencies": {
"@types/node": "^25.2.3",
"@typescript/native-preview": "^7.0.0-dev.20260217.1",
"@vitest/coverage-v8": "^4.0.18",
"changelogen": "^0.6.2",
"esbuild": "^0.27.3",
"mitata": "^1.0.34",
"obuild": "^0.4.28",
"oxfmt": "^0.33.0",
"oxlint": "^1.48.0",
"rollup": "^4.57.1",
"typescript": "^5.9.3",
"vitest": "^4.0.18"
},
"packageManager": "pnpm@10.30.0"
}