morphix-env 0.7.0 → 0.8.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/README.md +84 -210
- package/dist/SKILL.md +11 -2
- package/dist/cli.js +565 -79
- package/dist/index.d.ts +174 -0
- package/dist/index.js +732 -0
- package/package.json +16 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
interface SourceBase {
|
|
2
|
+
/** A later source may replace keys supplied by an earlier source. */
|
|
3
|
+
override?: boolean;
|
|
4
|
+
/** Only a missing local file source may be optional. */
|
|
5
|
+
optional?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface InfisicalSource extends SourceBase {
|
|
8
|
+
provider: 'infisical';
|
|
9
|
+
paths: string[];
|
|
10
|
+
projectId?: string;
|
|
11
|
+
siteUrl?: string;
|
|
12
|
+
env?: string;
|
|
13
|
+
envPrefix?: string;
|
|
14
|
+
}
|
|
15
|
+
interface LocalSource extends SourceBase {
|
|
16
|
+
provider: 'local';
|
|
17
|
+
files: string[];
|
|
18
|
+
}
|
|
19
|
+
interface DotenvxSource extends SourceBase {
|
|
20
|
+
provider: 'dotenvx';
|
|
21
|
+
files: string[];
|
|
22
|
+
}
|
|
23
|
+
interface KeychainSource extends SourceBase {
|
|
24
|
+
provider: 'os-keychain';
|
|
25
|
+
service: string;
|
|
26
|
+
platform?: 'macos';
|
|
27
|
+
}
|
|
28
|
+
interface DopplerSource extends SourceBase {
|
|
29
|
+
provider: 'doppler';
|
|
30
|
+
project: string;
|
|
31
|
+
config: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* External provider plugin: any executable named `mx-env-provider-<plugin>`
|
|
35
|
+
* found on PATH. It is invoked once per key with the key name as argv[1] and
|
|
36
|
+
* writes the value to stdout (one trailing line ending stripped). Provider
|
|
37
|
+
* login/bootstrap stays inside the plugin, never in repository config.
|
|
38
|
+
*/
|
|
39
|
+
interface PluginSource extends SourceBase {
|
|
40
|
+
provider: 'plugin';
|
|
41
|
+
plugin: string;
|
|
42
|
+
keys: string[];
|
|
43
|
+
}
|
|
44
|
+
type SecretSource = InfisicalSource | LocalSource | DotenvxSource | KeychainSource | DopplerSource | PluginSource;
|
|
45
|
+
interface ProfileDefinition {
|
|
46
|
+
sources: string[];
|
|
47
|
+
extends?: string;
|
|
48
|
+
}
|
|
49
|
+
type ProfileInput = string[] | ProfileDefinition;
|
|
50
|
+
interface MxEnvConfig {
|
|
51
|
+
/** Legacy Infisical configuration retained for backwards compatibility. */
|
|
52
|
+
infisical?: {
|
|
53
|
+
projectId?: string;
|
|
54
|
+
paths: string[];
|
|
55
|
+
siteUrl?: string;
|
|
56
|
+
/** Automatically add a prefix (such as VITE_) to loaded keys. */
|
|
57
|
+
envPrefix?: string;
|
|
58
|
+
};
|
|
59
|
+
/** Legacy local override files retained for backwards compatibility. */
|
|
60
|
+
envFiles?: string[];
|
|
61
|
+
/** Client __env.js generation configuration. */
|
|
62
|
+
generate?: {
|
|
63
|
+
out?: string;
|
|
64
|
+
filter?: string;
|
|
65
|
+
};
|
|
66
|
+
/** Named whole-source collections. Source values never belong in this file. */
|
|
67
|
+
sources?: Record<string, SecretSource>;
|
|
68
|
+
/** Named ordered source profiles. */
|
|
69
|
+
profiles?: Record<string, ProfileInput>;
|
|
70
|
+
/** Profile selected when a caller does not pass --profile. */
|
|
71
|
+
defaultProfile?: string;
|
|
72
|
+
}
|
|
73
|
+
interface LoadedConfig {
|
|
74
|
+
config: MxEnvConfig;
|
|
75
|
+
path: string;
|
|
76
|
+
baseDir: string;
|
|
77
|
+
exists: boolean;
|
|
78
|
+
}
|
|
79
|
+
interface ConfigLayers {
|
|
80
|
+
global: LoadedConfig;
|
|
81
|
+
project: LoadedConfig;
|
|
82
|
+
globalEnvFile: string;
|
|
83
|
+
}
|
|
84
|
+
interface LoadConfigOptions {
|
|
85
|
+
cwd?: string;
|
|
86
|
+
homeDir?: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Loads the two intentional configuration discovery points. Values are never
|
|
90
|
+
* read here; ~/.mx-env/.env is represented as a source by composition later.
|
|
91
|
+
*/
|
|
92
|
+
declare function loadConfigLayers(options?: LoadConfigOptions): ConfigLayers;
|
|
93
|
+
/**
|
|
94
|
+
* Returns human-readable validation problems without echoing provider values.
|
|
95
|
+
* Provider credentials deliberately have no place in the declared schema.
|
|
96
|
+
*/
|
|
97
|
+
declare function validateConfig(config: MxEnvConfig, label?: string): string[];
|
|
98
|
+
|
|
99
|
+
type SourceAvailability = 'loaded' | 'missing-optional' | 'skipped';
|
|
100
|
+
interface SourceEntry {
|
|
101
|
+
name: string;
|
|
102
|
+
source: SecretSource;
|
|
103
|
+
baseDir: string;
|
|
104
|
+
/** Internal conventional source. Never emitted as a user configuration declaration. */
|
|
105
|
+
globalImplicit?: boolean;
|
|
106
|
+
/** Legacy compatibility sources are allowed to skip missing Infisical setup. */
|
|
107
|
+
legacy?: boolean;
|
|
108
|
+
}
|
|
109
|
+
interface LoadedSource {
|
|
110
|
+
name: string;
|
|
111
|
+
provider: SecretSource['provider'];
|
|
112
|
+
values: Record<string, string>;
|
|
113
|
+
availability: SourceAvailability;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
interface ComposeOptions {
|
|
117
|
+
profile?: string | null;
|
|
118
|
+
noGlobal?: boolean;
|
|
119
|
+
noInfisical?: boolean;
|
|
120
|
+
envName?: string | null;
|
|
121
|
+
allowInsecureGlobal?: boolean;
|
|
122
|
+
envFiles?: string[];
|
|
123
|
+
baseEnvironment?: NodeJS.ProcessEnv;
|
|
124
|
+
homeDir?: string;
|
|
125
|
+
}
|
|
126
|
+
interface KeyProvenance {
|
|
127
|
+
key: string;
|
|
128
|
+
source: string;
|
|
129
|
+
provider: SecretSource['provider'];
|
|
130
|
+
precedence: number;
|
|
131
|
+
overriddenSources: string[];
|
|
132
|
+
}
|
|
133
|
+
interface SourceStatus {
|
|
134
|
+
name: string;
|
|
135
|
+
provider: SecretSource['provider'];
|
|
136
|
+
availability: LoadedSource['availability'];
|
|
137
|
+
keyCount: number;
|
|
138
|
+
}
|
|
139
|
+
interface EnvironmentComposition {
|
|
140
|
+
environment: NodeJS.ProcessEnv;
|
|
141
|
+
profileName: string;
|
|
142
|
+
sourceStatuses: SourceStatus[];
|
|
143
|
+
provenance: Record<string, KeyProvenance>;
|
|
144
|
+
/** Value-free source descriptors used by the one-shot editor. */
|
|
145
|
+
sourceEntries: SourceEntry[];
|
|
146
|
+
/** Kept only in memory for output redaction during this invocation. */
|
|
147
|
+
redactionValues: string[];
|
|
148
|
+
}
|
|
149
|
+
declare class CompositionError extends Error {
|
|
150
|
+
constructor(message: string);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Resolves sources in precedence order without mutating global process.env.
|
|
154
|
+
* A caller receives an environment object suitable for exactly one child run.
|
|
155
|
+
*/
|
|
156
|
+
declare function composeEnvironment(layers: ConfigLayers, options?: ComposeOptions): Promise<EnvironmentComposition>;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Redacts exact in-memory values while preserving normal stream output. This is
|
|
160
|
+
* deliberately not an exfiltration boundary: a child process can transform a
|
|
161
|
+
* value before printing it. It prevents the common accidental direct echo.
|
|
162
|
+
*/
|
|
163
|
+
declare class StreamingRedactor {
|
|
164
|
+
private readonly values;
|
|
165
|
+
private pending;
|
|
166
|
+
constructor(values: string[]);
|
|
167
|
+
write(chunk: Buffer | string): string;
|
|
168
|
+
flush(): string;
|
|
169
|
+
private incompletePrefixLength;
|
|
170
|
+
private redact;
|
|
171
|
+
private lastCompleteMatchEnd;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export { type ComposeOptions, CompositionError, type ConfigLayers, type EnvironmentComposition, type KeyProvenance, type LoadConfigOptions, type LoadedConfig, type MxEnvConfig, type ProfileDefinition, type ProfileInput, type SecretSource, type SourceEntry, type SourceStatus, StreamingRedactor, composeEnvironment, loadConfigLayers, validateConfig };
|