@effected/env 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Audience.js +1 -2
- package/EnvOverride.js +1 -2
- package/RuntimeEnv.js +1 -2
- package/TerminalEnv.js +1 -2
- package/index.d.ts +0 -10
- package/internal/agentCi.js +1 -2
- package/internal/colorDepth.js +1 -2
- package/internal/envRecord.js +1 -2
- package/internal/keys.js +1 -2
- package/internal/osc8/detect.js +1 -2
- package/internal/osc8/env.js +1 -2
- package/internal/osc8/semver.js +1 -2
- package/internal/osc8/terminals.js +1 -2
- package/internal/osc8/wrappers.js +1 -2
- package/package.json +1 -1
package/Audience.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CurrentRuntimeEnv } from "./RuntimeEnv.js";
|
|
2
2
|
import { Config, Context, Effect, Layer, Option } from "effect";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/Audience.ts
|
|
5
5
|
const KINDS = [
|
|
6
6
|
"human",
|
|
7
7
|
"agent",
|
|
@@ -90,5 +90,4 @@ var Audience = class Audience extends Context.Service()("@effected/env/Audience"
|
|
|
90
90
|
static detect = (env) => Option.isSome(env.agent) ? "agent" : Option.isSome(env.ci) ? "ci" : "human";
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
-
//#endregion
|
|
94
93
|
export { Audience };
|
package/EnvOverride.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Audience } from "./Audience.js";
|
|
2
2
|
import { Config, ConfigProvider, Effect, Option } from "effect";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/EnvOverride.ts
|
|
5
5
|
const isProvider = (source) => typeof source.load === "function";
|
|
6
6
|
/**
|
|
7
7
|
* Reads an environment variable that picks a mode within an audience.
|
|
@@ -105,5 +105,4 @@ var EnvOverride = class EnvOverride {
|
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
-
//#endregion
|
|
109
108
|
export { EnvOverride };
|
package/RuntimeEnv.js
CHANGED
|
@@ -4,7 +4,7 @@ import { detectOsc8 } from "./internal/osc8/detect.js";
|
|
|
4
4
|
import { allKeys } from "./internal/keys.js";
|
|
5
5
|
import { ConfigProvider, Context, Effect, Layer, Option, Schema } from "effect";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/RuntimeEnv.ts
|
|
8
8
|
/**
|
|
9
9
|
* An `Option` field that encodes `None` as `null` and decodes when its key is absent, so a persisted snapshot keeps
|
|
10
10
|
* decoding after a field is added.
|
|
@@ -113,5 +113,4 @@ var CurrentRuntimeEnv = class CurrentRuntimeEnv extends Context.Service()("@effe
|
|
|
113
113
|
}));
|
|
114
114
|
};
|
|
115
115
|
|
|
116
|
-
//#endregion
|
|
117
116
|
export { CurrentRuntimeEnv, RuntimeEnv };
|
package/TerminalEnv.js
CHANGED
|
@@ -4,7 +4,7 @@ import { detectOsc8 } from "./internal/osc8/detect.js";
|
|
|
4
4
|
import { allKeys } from "./internal/keys.js";
|
|
5
5
|
import { Context, Effect, Layer, Option, Stdio, Terminal } from "effect";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/TerminalEnv.ts
|
|
8
8
|
const make = (env, isTTY, columns) => {
|
|
9
9
|
const links = detectOsc8(env, isTTY.stdout, isTTY.stderr);
|
|
10
10
|
const fromEnv = /^\d+$/.test(env.COLUMNS ?? "") ? Number(env.COLUMNS) : 0;
|
|
@@ -140,5 +140,4 @@ var TerminalEnv = class TerminalEnv extends Context.Service()("@effected/env/Ter
|
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
142
|
|
|
143
|
-
//#endregion
|
|
144
143
|
export { TerminalEnv };
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ConfigProvider, Context, Effect, Layer, Option, Schema, Stdio, Terminal } from "effect";
|
|
2
|
-
//#region src/RuntimeEnv.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* The CI providers a {@link RuntimeEnv} names: `github-actions` when `GITHUB_ACTIONS` is set, `generic` for any other
|
|
5
4
|
* CI signal (`CI`, `CONTINUOUS_INTEGRATION`).
|
|
@@ -116,8 +115,6 @@ export declare class CurrentRuntimeEnv extends CurrentRuntimeEnv_base {
|
|
|
116
115
|
*/
|
|
117
116
|
static readonly layerTest: (overrides?: RuntimeEnvOverrides) => Layer.Layer<CurrentRuntimeEnv>;
|
|
118
117
|
}
|
|
119
|
-
//#endregion
|
|
120
|
-
//#region src/Audience.d.ts
|
|
121
118
|
/**
|
|
122
119
|
* Who the output is for: a person at a terminal, an AI agent, or a CI job.
|
|
123
120
|
*
|
|
@@ -208,16 +205,12 @@ export declare class Audience extends Audience_base {
|
|
|
208
205
|
*/
|
|
209
206
|
static readonly detect: (env: RuntimeEnv) => AudienceKind;
|
|
210
207
|
}
|
|
211
|
-
//#endregion
|
|
212
|
-
//#region src/ColorLevel.d.ts
|
|
213
208
|
/**
|
|
214
209
|
* The colour support of one output stream: none, 16 colours, 256 colours or truecolor.
|
|
215
210
|
*
|
|
216
211
|
* @public
|
|
217
212
|
*/
|
|
218
213
|
type ColorLevel = "none" | "basic" | "256" | "truecolor";
|
|
219
|
-
//#endregion
|
|
220
|
-
//#region src/EnvOverride.d.ts
|
|
221
214
|
/**
|
|
222
215
|
* Reads an environment variable that picks a mode within an audience.
|
|
223
216
|
*
|
|
@@ -297,8 +290,6 @@ export declare class EnvOverride {
|
|
|
297
290
|
readonly accepts: M;
|
|
298
291
|
}): Effect.Effect<Option.Option<M[AudienceKind][number]>, never, Audience>;
|
|
299
292
|
}
|
|
300
|
-
//#endregion
|
|
301
|
-
//#region src/TerminalEnv.d.ts
|
|
302
293
|
/**
|
|
303
294
|
* What one output stream can do.
|
|
304
295
|
*
|
|
@@ -443,6 +434,5 @@ export declare class TerminalEnv extends TerminalEnv_base {
|
|
|
443
434
|
*/
|
|
444
435
|
static colorLevel(_stream: "stdout"): Effect.Effect<ColorLevel, never, Stdio.Stdio>;
|
|
445
436
|
}
|
|
446
|
-
//#endregion
|
|
447
437
|
export type { AudienceKind, AudienceOptions, AudienceShape, CiName, ColorLevel, RuntimeEnvOverrides, StreamEnv, TerminalEnvOptions, TerminalEnvShape, TerminalEnvTestOptions };
|
|
448
438
|
//# sourceMappingURL=index.d.ts.map
|
package/internal/agentCi.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Option } from "effect";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/internal/agentCi.ts
|
|
4
4
|
const matches = (value, pattern) => !!value && pattern.test(value);
|
|
5
5
|
const AGENT_RULES = [
|
|
6
6
|
["claude", ["CLAUDECODE", "CLAUDE_CODE"]],
|
|
@@ -65,5 +65,4 @@ const agentCiKeys = [
|
|
|
65
65
|
"CONTINUOUS_INTEGRATION"
|
|
66
66
|
];
|
|
67
67
|
|
|
68
|
-
//#endregion
|
|
69
68
|
export { agentCiKeys, detectAgent, detectCi };
|
package/internal/colorDepth.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/colorDepth.ts
|
|
2
2
|
const TERM_ENVS = /* @__PURE__ */ new Map([
|
|
3
3
|
["eterm", "basic"],
|
|
4
4
|
["cons25", "basic"],
|
|
@@ -124,5 +124,4 @@ const colorKeys = [
|
|
|
124
124
|
...CI_ENVS.map(([name]) => name)
|
|
125
125
|
];
|
|
126
126
|
|
|
127
|
-
//#endregion
|
|
128
127
|
export { colorDepth, colorKeys };
|
package/internal/envRecord.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Config, Effect, Option } from "effect";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/internal/envRecord.ts
|
|
4
4
|
/**
|
|
5
5
|
* Drop an absent or empty value from a plain record, so it carries non-empty values only: the normalisation
|
|
6
6
|
* {@link readEnv} applies to what it reads, for a record a caller already holds.
|
|
@@ -20,5 +20,4 @@ const normalizeEnv = (record) => Object.fromEntries(Object.entries(record).filte
|
|
|
20
20
|
*/
|
|
21
21
|
const readEnv = (keys) => Effect.forEach(keys, (key) => Config.option(Config.String(key)).pipe(Effect.orElseSucceed(() => Option.none()), Effect.map((value) => [key, value]))).pipe(Effect.map((entries) => Object.fromEntries(entries.flatMap(([key, value]) => Option.isSome(value) && value.value !== "" ? [[key, value.value]] : []))));
|
|
22
22
|
|
|
23
|
-
//#endregion
|
|
24
23
|
export { normalizeEnv, readEnv };
|
package/internal/keys.js
CHANGED
|
@@ -2,7 +2,7 @@ import { agentCiKeys } from "./agentCi.js";
|
|
|
2
2
|
import { colorKeys } from "./colorDepth.js";
|
|
3
3
|
import { terminalKeys } from "./osc8/detect.js";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/internal/keys.ts
|
|
6
6
|
/**
|
|
7
7
|
* Every environment variable any detector reads: the union of the agent/CI, colour and terminal key lists, without
|
|
8
8
|
* duplicates.
|
|
@@ -15,5 +15,4 @@ const allKeys = [.../* @__PURE__ */ new Set([
|
|
|
15
15
|
...terminalKeys
|
|
16
16
|
])];
|
|
17
17
|
|
|
18
|
-
//#endregion
|
|
19
18
|
export { allKeys };
|
package/internal/osc8/detect.js
CHANGED
|
@@ -4,7 +4,7 @@ import { NO_CAPS, lookupTerminal } from "./terminals.js";
|
|
|
4
4
|
import { detectWrapper } from "./wrappers.js";
|
|
5
5
|
import { Option } from "effect";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/internal/osc8/detect.ts
|
|
8
8
|
const explanationFor = (reason, terminal, terminalVersion, wrapper) => {
|
|
9
9
|
switch (reason) {
|
|
10
10
|
case "force-env": return "FORCE_HYPERLINK env var is set";
|
|
@@ -144,5 +144,4 @@ const terminalKeys = [
|
|
|
144
144
|
"TERMINOLOGY"
|
|
145
145
|
];
|
|
146
146
|
|
|
147
|
-
//#endregion
|
|
148
147
|
export { detect, detectOsc8, terminalKeys };
|
package/internal/osc8/env.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/osc8/env.ts
|
|
2
2
|
const DEFAULT_FALSY = /* @__PURE__ */ new Set([
|
|
3
3
|
"0",
|
|
4
4
|
"false",
|
|
@@ -17,5 +17,4 @@ const envIsTruthy = (value, spec = "default") => {
|
|
|
17
17
|
return !DEFAULT_FALSY.has(value.toLowerCase());
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
//#endregion
|
|
21
20
|
export { envIsTruthy };
|
package/internal/osc8/semver.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/osc8/semver.ts
|
|
2
2
|
const SEMVER_RE = /^(\d+)(?:\.(\d+))?(?:\.(\d+))?/;
|
|
3
3
|
/**
|
|
4
4
|
* Compare two semver-like strings (`MAJOR[.MINOR[.PATCH]]`). Prerelease tags
|
|
@@ -42,5 +42,4 @@ const parseVteVersion = (raw) => {
|
|
|
42
42
|
*/
|
|
43
43
|
const parseKonsoleVersion = parseVteVersion;
|
|
44
44
|
|
|
45
|
-
//#endregion
|
|
46
45
|
export { compareSemver, parseKonsoleVersion, parseVteVersion };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseKonsoleVersion, parseVteVersion } from "./semver.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/internal/osc8/terminals.ts
|
|
4
4
|
const NO_CAPS = {
|
|
5
5
|
params: false,
|
|
6
6
|
fileUrls: false,
|
|
@@ -315,5 +315,4 @@ const lookupTerminal = (env) => {
|
|
|
315
315
|
return null;
|
|
316
316
|
};
|
|
317
317
|
|
|
318
|
-
//#endregion
|
|
319
318
|
export { NO_CAPS, lookupTerminal };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/osc8/wrappers.ts
|
|
2
2
|
/**
|
|
3
3
|
* Detect a multiplexer wrapper from the env. Conservative — `passesThrough`
|
|
4
4
|
* is always `false` because we cannot verify version or config without
|
|
@@ -19,5 +19,4 @@ const detectWrapper = (env) => {
|
|
|
19
19
|
return null;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
//#endregion
|
|
23
22
|
export { detectWrapper };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effected/env",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Effect-native environment detection: agent, CI, terminal colour level, hyperlinks, columns and audience — read once through Config, swapped in tests with layerTest",
|
|
6
6
|
"keywords": [
|