envprism 0.3.2-dev.95-1b62be2 → 0.4.1-dev-main.98-fbc96ec

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 CHANGED
@@ -6,8 +6,8 @@
6
6
 
7
7
  [![npm Version](https://img.shields.io/npm/v/envprism.svg?style=flat-square&color=4f46e5)](https://www.npmjs.com/package/envprism)
8
8
  [![Downloads](https://img.shields.io/npm/dm/envprism.svg?style=flat-square&color=4f46e5)](https://www.npmjs.com/package/envprism)
9
- [![Tests](https://img.shields.io/github/actions/workflow/status/TitusKirch/envprism/ci.yml?branch=main&style=flat-square&label=tests)](https://github.com/TitusKirch/envprism/actions/workflows/ci.yml)
10
- [![Bun](https://img.shields.io/badge/bun-1.3%2B-8993be?style=flat-square)](https://bun.sh/)
9
+ [![Tests](https://img.shields.io/github/actions/workflow/status/TitusKirch/envprism/ci.yml?event=pull_request&style=flat-square&label=tests)](https://github.com/TitusKirch/envprism/actions/workflows/ci.yml)
10
+ [![Bun](https://img.shields.io/badge/bun-1.3.14%2B-8993be?style=flat-square)](https://bun.sh/)
11
11
  [![License: MIT](https://img.shields.io/npm/l/envprism.svg?style=flat-square&color=10b981)](LICENSE)
12
12
 
13
13
  ![envprism TUI preview](.github/assets/demo.gif)
@@ -31,7 +31,7 @@ envprism treats the whole set as one thing: every file a column, every variable
31
31
  ## 📦 Install & run
32
32
 
33
33
  > [!IMPORTANT]
34
- > envprism runs on **[Bun](https://bun.sh/)** 1.3+, not Node. The TUI links a native core via `bun:ffi`, so `npx envprism` will **not** work — [install Bun](https://bun.sh/) first.
34
+ > envprism runs on **[Bun](https://bun.sh/)** 1.3.14+, not Node. The TUI links a native core via `bun:ffi`, so `npx envprism` will **not** work — [install Bun](https://bun.sh/) first.
35
35
 
36
36
  ```bash
37
37
  bun add -g envprism # install globally
@@ -64,7 +64,7 @@ Inside the TUI, press `?` for the full keybinding reference.
64
64
 
65
65
  ### Discovery & comparison
66
66
 
67
- - **🔍 Auto-discovery** — finds every `.env*` file in the current directory (or in `--paths a b c`); skips editor swap files and backups.
67
+ - **🔍 Auto-discovery** — finds every `.env*` file in the current directory, or in the directories and files you pass (`envprism diff a b`); skips editor swap files and backups.
68
68
  - **🧮 Matrix view** — rows are the union of every variable, columns are the files; the prism metaphor, literal.
69
69
  - **🎯 Smart base resolution** — `.env.example` is auto-promoted to base if present, otherwise the alphabetically-first file. Override with `--base file`.
70
70
  - **🎨 Per-cell diff icons** — `≠` value differs (yellow), `✗ missing` (red), `★` extra (key not in base, yellow), `⚠` placeholder (orange) — only the icon is coloured, values stay neutral.
@@ -172,12 +172,7 @@ Theme keys (all optional hex strings): `fg`, `fgDim`, `fgHeader`, `fgBase`, `fgS
172
172
 
173
173
  ## 🤝 Contributing
174
174
 
175
- PRs welcome. Conventional Commits required (enforced via commitlint). Husky runs the project's linters/formatters on `git commit`.
176
-
177
- > [!TIP]
178
- > Run `pnpm check:fix` before pushing — CI will catch what husky missed.
179
-
180
- See [CONTRIBUTING.md](CONTRIBUTING.md) for the full workflow.
175
+ PRs welcome — setup, branching, commit conventions and the local gate are in [CONTRIBUTING.md](CONTRIBUTING.md).
181
176
 
182
177
  ## 🛣️ Versioning
183
178
 
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env bun
2
- import { a as computeDiff, c as loadEnvprismConfig, o as formatDiffText, r as discoverEnvFiles, s as resolveBase, t as buildMatrix } from "../chunks/matrix-CG1Msljr.mjs";
2
+ import { a as computeDiff, c as loadEnvprismConfig, o as formatDiffText, r as discoverEnvFiles, s as resolveBase, t as buildMatrix } from "../chunks/matrix-CiLpV5eV.mjs";
3
3
  import { defineCommand, runMain } from "citty";
4
4
  import { spawn } from "node:child_process";
5
5
  import { writeFile } from "node:fs/promises";
6
6
  import consola from "consola";
7
7
  import { join, resolve } from "pathe";
8
- //#region src/commands/config/init.ts
8
+ // src/commands/config/init.ts
9
9
  /** Scaffold template, shared with `config edit` for first-time creation. */
10
10
  var CONFIG_TEMPLATE = `/**
11
11
  * envprism configuration.
@@ -68,7 +68,8 @@ var initCommand = defineCommand({
68
68
  }
69
69
  },
70
70
  async run({ args }) {
71
- const target = join(resolve(typeof args.out === "string" ? args.out : "."), "envprism.config.ts");
71
+ const dir = resolve(typeof args.out === "string" ? args.out : ".");
72
+ const target = join(dir, "envprism.config.ts");
72
73
  try {
73
74
  await writeFile(target, CONFIG_TEMPLATE, {
74
75
  encoding: "utf8",
@@ -85,8 +86,7 @@ var initCommand = defineCommand({
85
86
  consola.success(`Wrote ${target}`);
86
87
  }
87
88
  });
88
- //#endregion
89
- //#region src/commands/config/edit.ts
89
+ // src/commands/config/edit.ts
90
90
  var editCommand = defineCommand({
91
91
  meta: {
92
92
  name: "edit",
@@ -119,8 +119,38 @@ var editCommand = defineCommand({
119
119
  });
120
120
  }
121
121
  });
122
- //#endregion
123
- //#region src/commands/config/index.ts
122
+ // src/commands/config/path.ts
123
+ var pathCommand = defineCommand({
124
+ meta: {
125
+ name: "path",
126
+ description: "Print the resolved config file path (or note that defaults are used)."
127
+ },
128
+ args: { config: {
129
+ type: "string",
130
+ description: "Path to an envprism.config file (default: walk up from cwd)."
131
+ } },
132
+ async run({ args }) {
133
+ const { configFile, cwd } = await loadEnvprismConfig({ configFile: args.config });
134
+ if (configFile) process.stdout.write(configFile + "\n");
135
+ else consola.info(`No envprism.config found (searched up from ${cwd}); using built-in defaults.`);
136
+ }
137
+ });
138
+ // src/commands/config/show.ts
139
+ var showCommand = defineCommand({
140
+ meta: {
141
+ name: "show",
142
+ description: "Print the effective (merged) config as JSON."
143
+ },
144
+ args: { config: {
145
+ type: "string",
146
+ description: "Path to an envprism.config file (default: walk up from cwd)."
147
+ } },
148
+ async run({ args }) {
149
+ const { config } = await loadEnvprismConfig({ configFile: args.config });
150
+ process.stdout.write(JSON.stringify(config, null, 2) + "\n");
151
+ }
152
+ });
153
+ // src/commands/config/index.ts
124
154
  var configCommand = defineCommand({
125
155
  meta: {
126
156
  name: "config",
@@ -128,40 +158,25 @@ var configCommand = defineCommand({
128
158
  },
129
159
  subCommands: {
130
160
  init: initCommand,
131
- path: defineCommand({
132
- meta: {
133
- name: "path",
134
- description: "Print the resolved config file path (or note that defaults are used)."
135
- },
136
- args: { config: {
137
- type: "string",
138
- description: "Path to an envprism.config file (default: walk up from cwd)."
139
- } },
140
- async run({ args }) {
141
- const { configFile, cwd } = await loadEnvprismConfig({ configFile: args.config });
142
- if (configFile) process.stdout.write(configFile + "\n");
143
- else consola.info(`No envprism.config found (searched up from ${cwd}); using built-in defaults.`);
144
- }
145
- }),
146
- show: defineCommand({
147
- meta: {
148
- name: "show",
149
- description: "Print the effective (merged) config as JSON."
150
- },
151
- args: { config: {
152
- type: "string",
153
- description: "Path to an envprism.config file (default: walk up from cwd)."
154
- } },
155
- async run({ args }) {
156
- const { config } = await loadEnvprismConfig({ configFile: args.config });
157
- process.stdout.write(JSON.stringify(config, null, 2) + "\n");
158
- }
159
- }),
161
+ path: pathCommand,
162
+ show: showCommand,
160
163
  edit: editCommand
161
164
  }
162
165
  });
163
- //#endregion
164
- //#region src/commands/diff.ts
166
+ // src/commands/paths.ts
167
+ /**
168
+ * The paths a command should scan. citty puts only the first positional into
169
+ * a named positional arg and every positional into `_`, so `_` wins whenever
170
+ * it holds anything; otherwise the named arg, then the configured fallback.
171
+ */
172
+ function collectPaths(args, fallback) {
173
+ if (Array.isArray(args._) && args._.length > 0) return args._.map(String);
174
+ const { paths } = args;
175
+ if (Array.isArray(paths)) return paths.map(String);
176
+ if (typeof paths === "string" && paths.length > 0) return [paths];
177
+ return fallback;
178
+ }
179
+ // src/commands/diff.ts
165
180
  var diffCommand = defineCommand({
166
181
  meta: {
167
182
  name: "diff",
@@ -171,7 +186,7 @@ var diffCommand = defineCommand({
171
186
  paths: {
172
187
  type: "positional",
173
188
  required: false,
174
- description: "Directory or files to scan (defaults to cwd)."
189
+ description: "Directories or files to scan (defaults to cwd)."
175
190
  },
176
191
  base: {
177
192
  type: "string",
@@ -192,7 +207,8 @@ var diffCommand = defineCommand({
192
207
  },
193
208
  async run({ args }) {
194
209
  const { config } = await loadEnvprismConfig({ configFile: args.config });
195
- const files = await discoverEnvFiles(collectPaths$1(args.paths, config.discovery.paths).map((p) => resolve(p)), {
210
+ const inputs = collectPaths(args, config.discovery.paths);
211
+ const files = await discoverEnvFiles(inputs.map((p) => resolve(p)), {
196
212
  skipSuffixes: config.discovery.skipSuffixes,
197
213
  exampleFirst: config.discovery.exampleFirst
198
214
  });
@@ -208,7 +224,8 @@ var diffCommand = defineCommand({
208
224
  consola.error("Could not resolve a base file.");
209
225
  process.exit(1);
210
226
  }
211
- const report = computeDiff(buildMatrix(files, base));
227
+ const matrix = buildMatrix(files, base);
228
+ const report = computeDiff(matrix);
212
229
  if (args.check) process.exit(report.inSync ? 0 : config.diff.checkExitCode);
213
230
  if (args.json ?? config.diff.json) {
214
231
  process.stdout.write(JSON.stringify(report, null, 2) + "\n");
@@ -217,20 +234,15 @@ var diffCommand = defineCommand({
217
234
  process.stdout.write(formatDiffText(report));
218
235
  }
219
236
  });
220
- function collectPaths$1(arg, fallback) {
221
- if (Array.isArray(arg)) return arg.map(String);
222
- if (typeof arg === "string" && arg.length > 0) return [arg];
223
- return fallback;
224
- }
225
- //#endregion
226
- //#region src/commands/tui.ts
237
+ // src/commands/tui.ts
227
238
  /**
228
239
  * Resolve the matrix and boot the TUI. Shared between the explicit `tui`
229
240
  * subcommand and the default-no-subcommand path in `rootCommand`.
230
241
  */
231
242
  async function runTui(args) {
232
243
  const { config } = await loadEnvprismConfig({ configFile: args.config });
233
- const files = await discoverEnvFiles(collectPaths(args.paths, config.discovery.paths).map((p) => resolve(p)), {
244
+ const inputs = collectPaths(args, config.discovery.paths);
245
+ const files = await discoverEnvFiles(inputs.map((p) => resolve(p)), {
234
246
  skipSuffixes: config.discovery.skipSuffixes,
235
247
  exampleFirst: config.discovery.exampleFirst
236
248
  });
@@ -247,7 +259,7 @@ async function runTui(args) {
247
259
  process.exit(1);
248
260
  }
249
261
  const matrix = buildMatrix(files, base);
250
- const { runMatrixTui } = await import("../chunks/app-Bp7QXiLx.mjs");
262
+ const { runMatrixTui } = await import("../chunks/app-BqQuZiRW.mjs");
251
263
  await runMatrixTui(matrix, config);
252
264
  }
253
265
  var tuiCommand = defineCommand({
@@ -259,7 +271,7 @@ var tuiCommand = defineCommand({
259
271
  paths: {
260
272
  type: "positional",
261
273
  required: false,
262
- description: "Directory or files to scan (defaults to cwd)."
274
+ description: "Directories or files to scan (defaults to cwd)."
263
275
  },
264
276
  base: {
265
277
  type: "string",
@@ -273,26 +285,19 @@ var tuiCommand = defineCommand({
273
285
  async run({ args }) {
274
286
  await runTui({
275
287
  paths: args.paths,
288
+ _: args._,
276
289
  base: args.base,
277
290
  config: args.config
278
291
  });
279
292
  }
280
293
  });
281
- function collectPaths(arg, fallback) {
282
- if (Array.isArray(arg)) return arg.map(String);
283
- if (typeof arg === "string" && arg.length > 0) return [arg];
284
- return fallback;
285
- }
286
- //#endregion
287
- //#region src/cli.ts
294
+ // src/cli.ts
288
295
  var SUBCOMMANDS = /* @__PURE__ */ new Set([
289
296
  "tui",
290
297
  "diff",
291
298
  "config"
292
299
  ]);
293
- //#endregion
294
- //#region src/bin/envprism.ts
295
- runMain(defineCommand({
300
+ var rootCommand = defineCommand({
296
301
  meta: {
297
302
  name: "envprism",
298
303
  description: "TUI-based env file manager — refract one set of variables into many environment views."
@@ -307,7 +312,8 @@ runMain(defineCommand({
307
312
  if (firstPositional && SUBCOMMANDS.has(firstPositional)) return;
308
313
  await runTui({});
309
314
  }
310
- }));
311
- //#endregion
315
+ });
316
+ // src/bin/envprism.ts
317
+ runMain(rootCommand);
312
318
 
313
319
  //# sourceMappingURL=envprism.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"envprism.mjs","names":[],"sources":["../../src/commands/config/init.ts","../../src/commands/config/edit.ts","../../src/commands/config/path.ts","../../src/commands/config/show.ts","../../src/commands/config/index.ts","../../src/commands/diff.ts","../../src/commands/tui.ts","../../src/cli.ts","../../src/bin/envprism.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { defineCommand } from 'citty';\nimport consola from 'consola';\nimport { join, resolve } from 'pathe';\n\n/** Scaffold template, shared with `config edit` for first-time creation. */\nexport const CONFIG_TEMPLATE = `/**\n * envprism configuration.\n *\n * For type-safe authoring, install envprism and switch to:\n * import { defineEnvprismConfig } from 'envprism/config';\n * export default defineEnvprismConfig({ ... });\n *\n * @type {import('envprism/config').EnvprismUserConfig}\n */\nexport default {\n discovery: {\n // paths: ['.'],\n // skipSuffixesExtra: ['.tmp'],\n // exampleFirst: true\n },\n base: {\n name: '.env.example'\n // priority: ['.env.shared']\n },\n heuristics: {\n // secretTokensExtra: ['JWT'],\n // placeholdersExtra: ['set[_-]?me'],\n grouping: 'auto'\n },\n diff: {\n json: false,\n checkExitCode: 1\n },\n tui: {\n theme: {\n // fgBase: '#82aaff'\n },\n layout: {\n keyColWidth: 22,\n valueColMin: 18,\n sidebarWidth: 30,\n rowGap: 0,\n cellPadX: 1\n },\n undoLimit: 50,\n maskSecrets: true\n }\n};\n`;\n\nexport const initCommand = defineCommand({\n meta: {\n name: 'init',\n description: 'Scaffold an envprism.config.ts with documented defaults.'\n },\n args: {\n out: {\n type: 'positional',\n required: false,\n description: 'Directory to write envprism.config.ts into (default: cwd).'\n },\n force: {\n type: 'boolean',\n description: 'Overwrite an existing config file.'\n }\n },\n async run({ args }) {\n const dir = resolve(typeof args.out === 'string' ? args.out : '.');\n const target = join(dir, 'envprism.config.ts');\n try {\n await writeFile(target, CONFIG_TEMPLATE, {\n encoding: 'utf8',\n flag: args.force ? 'w' : 'wx'\n });\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'EEXIST') {\n consola.error(`${target} already exists. Use --force to overwrite.`);\n process.exitCode = 1;\n return;\n }\n throw err;\n }\n consola.success(`Wrote ${target}`);\n }\n});\n","import { spawn } from 'node:child_process';\nimport { writeFile } from 'node:fs/promises';\nimport { defineCommand } from 'citty';\nimport consola from 'consola';\nimport { resolve } from 'pathe';\nimport { CONFIG_TEMPLATE } from '@/commands/config/init.ts';\nimport { loadEnvprismConfig } from '@/config/load.ts';\n\nexport const editCommand = defineCommand({\n meta: {\n name: 'edit',\n description:\n 'Open the config in $EDITOR (creates it in cwd if none exists).'\n },\n args: {\n config: {\n type: 'string',\n description:\n 'Path to an envprism.config file (default: walk up from cwd).'\n }\n },\n async run({ args }) {\n let { configFile } = await loadEnvprismConfig({ configFile: args.config });\n\n if (!configFile) {\n configFile = resolve('envprism.config.ts');\n try {\n await writeFile(configFile, CONFIG_TEMPLATE, {\n encoding: 'utf8',\n flag: 'wx'\n });\n consola.info(`Created ${configFile}`);\n } catch {\n // Created concurrently or already present — open whatever is there.\n }\n }\n\n const editor = process.env.VISUAL || process.env.EDITOR || 'nano';\n await new Promise<void>((res, rej) => {\n const child = spawn(editor, [configFile!], { stdio: 'inherit' });\n child.on('error', rej);\n child.on('exit', (code) => {\n if (code && code !== 0) {\n consola.warn(`${editor} exited with code ${code}.`);\n }\n res();\n });\n });\n }\n});\n","import { defineCommand } from 'citty';\nimport consola from 'consola';\nimport { loadEnvprismConfig } from '@/config/load.ts';\n\nexport const pathCommand = defineCommand({\n meta: {\n name: 'path',\n description:\n 'Print the resolved config file path (or note that defaults are used).'\n },\n args: {\n config: {\n type: 'string',\n description:\n 'Path to an envprism.config file (default: walk up from cwd).'\n }\n },\n async run({ args }) {\n const { configFile, cwd } = await loadEnvprismConfig({\n configFile: args.config\n });\n if (configFile) {\n // Path goes to stdout so it can be piped; the not-found note is on stderr.\n process.stdout.write(configFile + '\\n');\n } else {\n consola.info(\n `No envprism.config found (searched up from ${cwd}); using built-in defaults.`\n );\n }\n }\n});\n","import { defineCommand } from 'citty';\nimport { loadEnvprismConfig } from '@/config/load.ts';\n\nexport const showCommand = defineCommand({\n meta: {\n name: 'show',\n description: 'Print the effective (merged) config as JSON.'\n },\n args: {\n config: {\n type: 'string',\n description:\n 'Path to an envprism.config file (default: walk up from cwd).'\n }\n },\n async run({ args }) {\n const { config } = await loadEnvprismConfig({ configFile: args.config });\n process.stdout.write(JSON.stringify(config, null, 2) + '\\n');\n }\n});\n","import { defineCommand } from 'citty';\nimport { editCommand } from '@/commands/config/edit.ts';\nimport { initCommand } from '@/commands/config/init.ts';\nimport { pathCommand } from '@/commands/config/path.ts';\nimport { showCommand } from '@/commands/config/show.ts';\n\nexport const configCommand = defineCommand({\n meta: {\n name: 'config',\n description: 'Inspect and manage the envprism config.'\n },\n subCommands: {\n init: initCommand,\n path: pathCommand,\n show: showCommand,\n edit: editCommand\n }\n});\n","import { defineCommand } from 'citty';\nimport consola from 'consola';\nimport { resolve } from 'pathe';\nimport { loadEnvprismConfig } from '@/config/load.ts';\nimport { resolveBase } from '@/core/base.ts';\nimport { computeDiff, formatDiffText } from '@/core/diff.ts';\nimport { discoverEnvFiles } from '@/core/discover.ts';\nimport { buildMatrix } from '@/core/matrix.ts';\n\nexport const diffCommand = defineCommand({\n meta: {\n name: 'diff',\n description: 'Print the drift between .env* files compared to a base.'\n },\n args: {\n paths: {\n type: 'positional',\n required: false,\n description: 'Directory or files to scan (defaults to cwd).'\n },\n base: {\n type: 'string',\n description: 'Base file to diff against (defaults to .env.example).'\n },\n json: {\n type: 'boolean',\n description: 'Emit JSON instead of a text table.'\n },\n check: {\n type: 'boolean',\n description:\n 'Suppress output and exit 1 when any file drifts from the base.'\n },\n config: {\n type: 'string',\n description:\n 'Path to an envprism.config file (default: walk up from cwd).'\n }\n },\n async run({ args }) {\n const { config } = await loadEnvprismConfig({ configFile: args.config });\n const inputs = collectPaths(args.paths, config.discovery.paths);\n const files = await discoverEnvFiles(\n inputs.map((p) => resolve(p)),\n {\n skipSuffixes: config.discovery.skipSuffixes,\n exampleFirst: config.discovery.exampleFirst\n }\n );\n\n if (files.length === 0) {\n if (!args.check) consola.warn('No .env* files found.');\n process.exit(args.check ? 0 : 1);\n }\n\n const base = resolveBase(files, args.base, {\n name: config.base.name,\n priority: config.base.priority\n });\n if (!base) {\n consola.error('Could not resolve a base file.');\n process.exit(1);\n }\n\n const matrix = buildMatrix(files, base);\n const report = computeDiff(matrix);\n\n if (args.check) {\n process.exit(report.inSync ? 0 : config.diff.checkExitCode);\n }\n\n const json = args.json ?? config.diff.json;\n if (json) {\n process.stdout.write(JSON.stringify(report, null, 2) + '\\n');\n return;\n }\n\n process.stdout.write(formatDiffText(report));\n }\n});\n\nfunction collectPaths(arg: unknown, fallback: string[]): string[] {\n if (Array.isArray(arg)) return arg.map(String);\n if (typeof arg === 'string' && arg.length > 0) return [arg];\n return fallback;\n}\n","import { defineCommand } from 'citty';\nimport consola from 'consola';\nimport { resolve } from 'pathe';\nimport { loadEnvprismConfig } from '@/config/load.ts';\nimport { resolveBase } from '@/core/base.ts';\nimport { discoverEnvFiles } from '@/core/discover.ts';\nimport { buildMatrix } from '@/core/matrix.ts';\n\ninterface TuiInvocation {\n paths?: string | string[];\n base?: string;\n config?: string;\n}\n\n/**\n * Resolve the matrix and boot the TUI. Shared between the explicit `tui`\n * subcommand and the default-no-subcommand path in `rootCommand`.\n */\nexport async function runTui(args: TuiInvocation): Promise<void> {\n const { config } = await loadEnvprismConfig({ configFile: args.config });\n const inputs = collectPaths(args.paths, config.discovery.paths);\n const files = await discoverEnvFiles(\n inputs.map((p) => resolve(p)),\n {\n skipSuffixes: config.discovery.skipSuffixes,\n exampleFirst: config.discovery.exampleFirst\n }\n );\n\n if (files.length === 0) {\n consola.warn('No .env* files found.');\n process.exit(1);\n }\n\n const base = resolveBase(files, args.base, {\n name: config.base.name,\n priority: config.base.priority\n });\n if (!base) {\n consola.error('Could not resolve a base file.');\n process.exit(1);\n }\n\n const matrix = buildMatrix(files, base);\n\n // Dynamic import keeps @opentui/core out of the bundle path used by the\n // `diff` subcommand, so users running diff on Node never hit Bun-only code.\n const { runMatrixTui } = await import('../tui/app.ts');\n await runMatrixTui(matrix, config);\n}\n\nexport const tuiCommand = defineCommand({\n meta: {\n name: 'tui',\n description: 'Open the interactive matrix view (default command).'\n },\n args: {\n paths: {\n type: 'positional',\n required: false,\n description: 'Directory or files to scan (defaults to cwd).'\n },\n base: {\n type: 'string',\n description: 'Base file to diff against (defaults to .env.example).'\n },\n config: {\n type: 'string',\n description:\n 'Path to an envprism.config file (default: walk up from cwd).'\n }\n },\n async run({ args }) {\n await runTui({ paths: args.paths, base: args.base, config: args.config });\n }\n});\n\nfunction collectPaths(arg: unknown, fallback: string[]): string[] {\n if (Array.isArray(arg)) return arg.map(String);\n if (typeof arg === 'string' && arg.length > 0) return [arg];\n return fallback;\n}\n","import { defineCommand } from 'citty';\nimport { configCommand } from '@/commands/config/index.ts';\nimport { diffCommand } from '@/commands/diff.ts';\nimport { runTui, tuiCommand } from '@/commands/tui.ts';\n\nconst SUBCOMMANDS = new Set(['tui', 'diff', 'config']);\n\nexport const rootCommand = defineCommand({\n meta: {\n name: 'envprism',\n description:\n 'TUI-based env file manager — refract one set of variables into many environment views.'\n },\n subCommands: {\n tui: tuiCommand,\n diff: diffCommand,\n config: configCommand\n },\n // citty 0.1.6 invokes the root `run` after a matched subcommand returns,\n // so guard against double-execution by bailing when the first positional\n // arg names a known subcommand. With no args at all we launch the TUI in\n // the cwd, which is the documented default.\n async run({ rawArgs }) {\n const firstPositional = rawArgs.find((a) => !a.startsWith('-'));\n if (firstPositional && SUBCOMMANDS.has(firstPositional)) return;\n await runTui({});\n }\n});\n","import { runMain } from 'citty';\nimport { rootCommand } from '@/cli.ts';\n\nrunMain(rootCommand);\n"],"mappings":";;;;;;;;;AAMA,IAAa,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6C/B,IAAa,cAAc,cAAc;CACvC,MAAM;EACJ,MAAM;EACN,aAAa;CACf;CACA,MAAM;EACJ,KAAK;GACH,MAAM;GACN,UAAU;GACV,aAAa;EACf;EACA,OAAO;GACL,MAAM;GACN,aAAa;EACf;CACF;CACA,MAAM,IAAI,EAAE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AU,OAAO,KAAK;CACxB,CAAC;CACD,IAAI,CAAC,MAAM;EACT,QAAQ,MAAM,gCAAgC;EAC9C,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,SAAS,YAAY,OAAO,IAAI;CAItC,MAAM,EAAE,iBAAiB,MAAM,OAAO;CACtC,MAAM,aAAa,QAAQ,MAAM;AACnC;AAEA,IAAa,aAAa,cAAc;CACtC,MAAM;EACJ,MAAM;EACN,aAAa;CACf;CACA,MAAM;EACJ,OAAO;GACL,MAAM;GACN,UAAU;GACV,aAAa;EACf;EACA,MAAM;GACJ,MAAM;GACN,aAAa;EACf;EACA,QAAQ;GACN,MAAM;GACN,aACE;EACJ;CACF;CACA,MAAM,IAAI,EAAE,QAAQ;EAClB,MAAM,OAAO;GAAE,OAAO,KAAK;GAAO,MAAM,KAAK;GAAM,QAAQ,KAAK;EAAO,CAAC;CAC1E;AACF,CAAC;AAED,SAAS,aAAa,KAAc,UAA8B;CAChE,IAAI,MAAM,QAAQ,GAAG,GAAG,OAAO,IAAI,IAAI,MAAM;CAC7C,IAAI,OAAO,QAAQ,YAAY,IAAI,SAAS,GAAG,OAAO,CAAC,GAAG;CAC1D,OAAO;AACT;;;AC5EA,IAAM,8BAAc,IAAI,IAAI;CAAC;CAAO;CAAQ;AAAQ,CAAC;;;ACFrD,QDI2B,cAAc;CACvC,MAAM;EACJ,MAAM;EACN,aACE;CACJ;CACA,aAAa;EACX,KAAK;EACL,MAAM;EACN,QAAQ;CACV;CAKA,MAAM,IAAI,EAAE,WAAW;EACrB,MAAM,kBAAkB,QAAQ,MAAM,MAAM,CAAC,EAAE,WAAW,GAAG,CAAC;EAC9D,IAAI,mBAAmB,YAAY,IAAI,eAAe,GAAG;EACzD,MAAM,OAAO,CAAC,CAAC;CACjB;AACF,CCxBQ,CAAW"}
1
+ {"version":3,"file":"envprism.mjs","names":[],"sources":["../../src/commands/config/init.ts","../../src/commands/config/edit.ts","../../src/commands/config/path.ts","../../src/commands/config/show.ts","../../src/commands/config/index.ts","../../src/commands/paths.ts","../../src/commands/diff.ts","../../src/commands/tui.ts","../../src/cli.ts","../../src/bin/envprism.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { defineCommand } from 'citty';\nimport consola from 'consola';\nimport { join, resolve } from 'pathe';\n\n/** Scaffold template, shared with `config edit` for first-time creation. */\nexport const CONFIG_TEMPLATE = `/**\n * envprism configuration.\n *\n * For type-safe authoring, install envprism and switch to:\n * import { defineEnvprismConfig } from 'envprism/config';\n * export default defineEnvprismConfig({ ... });\n *\n * @type {import('envprism/config').EnvprismUserConfig}\n */\nexport default {\n discovery: {\n // paths: ['.'],\n // skipSuffixesExtra: ['.tmp'],\n // exampleFirst: true\n },\n base: {\n name: '.env.example'\n // priority: ['.env.shared']\n },\n heuristics: {\n // secretTokensExtra: ['JWT'],\n // placeholdersExtra: ['set[_-]?me'],\n grouping: 'auto'\n },\n diff: {\n json: false,\n checkExitCode: 1\n },\n tui: {\n theme: {\n // fgBase: '#82aaff'\n },\n layout: {\n keyColWidth: 22,\n valueColMin: 18,\n sidebarWidth: 30,\n rowGap: 0,\n cellPadX: 1\n },\n undoLimit: 50,\n maskSecrets: true\n }\n};\n`;\n\nexport const initCommand = defineCommand({\n meta: {\n name: 'init',\n description: 'Scaffold an envprism.config.ts with documented defaults.'\n },\n args: {\n out: {\n type: 'positional',\n required: false,\n description: 'Directory to write envprism.config.ts into (default: cwd).'\n },\n force: {\n type: 'boolean',\n description: 'Overwrite an existing config file.'\n }\n },\n async run({ args }) {\n const dir = resolve(typeof args.out === 'string' ? args.out : '.');\n const target = join(dir, 'envprism.config.ts');\n try {\n await writeFile(target, CONFIG_TEMPLATE, {\n encoding: 'utf8',\n flag: args.force ? 'w' : 'wx'\n });\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'EEXIST') {\n consola.error(`${target} already exists. Use --force to overwrite.`);\n process.exitCode = 1;\n return;\n }\n throw err;\n }\n consola.success(`Wrote ${target}`);\n }\n});\n","import { spawn } from 'node:child_process';\nimport { writeFile } from 'node:fs/promises';\nimport { defineCommand } from 'citty';\nimport consola from 'consola';\nimport { resolve } from 'pathe';\nimport { CONFIG_TEMPLATE } from '@/commands/config/init.ts';\nimport { loadEnvprismConfig } from '@/config/load.ts';\n\nexport const editCommand = defineCommand({\n meta: {\n name: 'edit',\n description:\n 'Open the config in $EDITOR (creates it in cwd if none exists).'\n },\n args: {\n config: {\n type: 'string',\n description:\n 'Path to an envprism.config file (default: walk up from cwd).'\n }\n },\n async run({ args }) {\n let { configFile } = await loadEnvprismConfig({ configFile: args.config });\n\n if (!configFile) {\n configFile = resolve('envprism.config.ts');\n try {\n await writeFile(configFile, CONFIG_TEMPLATE, {\n encoding: 'utf8',\n flag: 'wx'\n });\n consola.info(`Created ${configFile}`);\n } catch {\n // Created concurrently or already present — open whatever is there.\n }\n }\n\n const editor = process.env.VISUAL || process.env.EDITOR || 'nano';\n await new Promise<void>((res, rej) => {\n const child = spawn(editor, [configFile!], { stdio: 'inherit' });\n child.on('error', rej);\n child.on('exit', (code) => {\n if (code && code !== 0) {\n consola.warn(`${editor} exited with code ${code}.`);\n }\n res();\n });\n });\n }\n});\n","import { defineCommand } from 'citty';\nimport consola from 'consola';\nimport { loadEnvprismConfig } from '@/config/load.ts';\n\nexport const pathCommand = defineCommand({\n meta: {\n name: 'path',\n description:\n 'Print the resolved config file path (or note that defaults are used).'\n },\n args: {\n config: {\n type: 'string',\n description:\n 'Path to an envprism.config file (default: walk up from cwd).'\n }\n },\n async run({ args }) {\n const { configFile, cwd } = await loadEnvprismConfig({\n configFile: args.config\n });\n if (configFile) {\n // Path goes to stdout so it can be piped; the not-found note is on stderr.\n process.stdout.write(configFile + '\\n');\n } else {\n consola.info(\n `No envprism.config found (searched up from ${cwd}); using built-in defaults.`\n );\n }\n }\n});\n","import { defineCommand } from 'citty';\nimport { loadEnvprismConfig } from '@/config/load.ts';\n\nexport const showCommand = defineCommand({\n meta: {\n name: 'show',\n description: 'Print the effective (merged) config as JSON.'\n },\n args: {\n config: {\n type: 'string',\n description:\n 'Path to an envprism.config file (default: walk up from cwd).'\n }\n },\n async run({ args }) {\n const { config } = await loadEnvprismConfig({ configFile: args.config });\n process.stdout.write(JSON.stringify(config, null, 2) + '\\n');\n }\n});\n","import { defineCommand } from 'citty';\nimport { editCommand } from '@/commands/config/edit.ts';\nimport { initCommand } from '@/commands/config/init.ts';\nimport { pathCommand } from '@/commands/config/path.ts';\nimport { showCommand } from '@/commands/config/show.ts';\n\nexport const configCommand = defineCommand({\n meta: {\n name: 'config',\n description: 'Inspect and manage the envprism config.'\n },\n subCommands: {\n init: initCommand,\n path: pathCommand,\n show: showCommand,\n edit: editCommand\n }\n});\n","/**\n * The paths a command should scan. citty puts only the first positional into\n * a named positional arg and every positional into `_`, so `_` wins whenever\n * it holds anything; otherwise the named arg, then the configured fallback.\n */\nexport function collectPaths(\n args: { paths?: unknown; _?: unknown },\n fallback: string[]\n): string[] {\n if (Array.isArray(args._) && args._.length > 0) return args._.map(String);\n const { paths } = args;\n if (Array.isArray(paths)) return paths.map(String);\n if (typeof paths === 'string' && paths.length > 0) return [paths];\n return fallback;\n}\n","import { defineCommand } from 'citty';\nimport consola from 'consola';\nimport { resolve } from 'pathe';\nimport { loadEnvprismConfig } from '@/config/load.ts';\nimport { resolveBase } from '@/core/base.ts';\nimport { computeDiff, formatDiffText } from '@/core/diff.ts';\nimport { discoverEnvFiles } from '@/core/discover.ts';\nimport { buildMatrix } from '@/core/matrix.ts';\nimport { collectPaths } from '@/commands/paths.ts';\n\nexport const diffCommand = defineCommand({\n meta: {\n name: 'diff',\n description: 'Print the drift between .env* files compared to a base.'\n },\n args: {\n paths: {\n type: 'positional',\n required: false,\n description: 'Directories or files to scan (defaults to cwd).'\n },\n base: {\n type: 'string',\n description: 'Base file to diff against (defaults to .env.example).'\n },\n json: {\n type: 'boolean',\n description: 'Emit JSON instead of a text table.'\n },\n check: {\n type: 'boolean',\n description:\n 'Suppress output and exit 1 when any file drifts from the base.'\n },\n config: {\n type: 'string',\n description:\n 'Path to an envprism.config file (default: walk up from cwd).'\n }\n },\n async run({ args }) {\n const { config } = await loadEnvprismConfig({ configFile: args.config });\n const inputs = collectPaths(args, config.discovery.paths);\n const files = await discoverEnvFiles(\n inputs.map((p) => resolve(p)),\n {\n skipSuffixes: config.discovery.skipSuffixes,\n exampleFirst: config.discovery.exampleFirst\n }\n );\n\n if (files.length === 0) {\n if (!args.check) consola.warn('No .env* files found.');\n process.exit(args.check ? 0 : 1);\n }\n\n const base = resolveBase(files, args.base, {\n name: config.base.name,\n priority: config.base.priority\n });\n if (!base) {\n consola.error('Could not resolve a base file.');\n process.exit(1);\n }\n\n const matrix = buildMatrix(files, base);\n const report = computeDiff(matrix);\n\n if (args.check) {\n process.exit(report.inSync ? 0 : config.diff.checkExitCode);\n }\n\n const json = args.json ?? config.diff.json;\n if (json) {\n process.stdout.write(JSON.stringify(report, null, 2) + '\\n');\n return;\n }\n\n process.stdout.write(formatDiffText(report));\n }\n});\n","import { defineCommand } from 'citty';\nimport consola from 'consola';\nimport { resolve } from 'pathe';\nimport { loadEnvprismConfig } from '@/config/load.ts';\nimport { resolveBase } from '@/core/base.ts';\nimport { discoverEnvFiles } from '@/core/discover.ts';\nimport { buildMatrix } from '@/core/matrix.ts';\nimport { collectPaths } from '@/commands/paths.ts';\n\ninterface TuiInvocation {\n paths?: string | string[];\n _?: string[];\n base?: string;\n config?: string;\n}\n\n/**\n * Resolve the matrix and boot the TUI. Shared between the explicit `tui`\n * subcommand and the default-no-subcommand path in `rootCommand`.\n */\nexport async function runTui(args: TuiInvocation): Promise<void> {\n const { config } = await loadEnvprismConfig({ configFile: args.config });\n const inputs = collectPaths(args, config.discovery.paths);\n const files = await discoverEnvFiles(\n inputs.map((p) => resolve(p)),\n {\n skipSuffixes: config.discovery.skipSuffixes,\n exampleFirst: config.discovery.exampleFirst\n }\n );\n\n if (files.length === 0) {\n consola.warn('No .env* files found.');\n process.exit(1);\n }\n\n const base = resolveBase(files, args.base, {\n name: config.base.name,\n priority: config.base.priority\n });\n if (!base) {\n consola.error('Could not resolve a base file.');\n process.exit(1);\n }\n\n const matrix = buildMatrix(files, base);\n\n // Dynamic import keeps @opentui/core out of the bundle path used by the\n // `diff` subcommand, so users running diff on Node never hit Bun-only code.\n const { runMatrixTui } = await import('../tui/app.ts');\n await runMatrixTui(matrix, config);\n}\n\nexport const tuiCommand = defineCommand({\n meta: {\n name: 'tui',\n description: 'Open the interactive matrix view (default command).'\n },\n args: {\n paths: {\n type: 'positional',\n required: false,\n description: 'Directories or files to scan (defaults to cwd).'\n },\n base: {\n type: 'string',\n description: 'Base file to diff against (defaults to .env.example).'\n },\n config: {\n type: 'string',\n description:\n 'Path to an envprism.config file (default: walk up from cwd).'\n }\n },\n async run({ args }) {\n await runTui({\n paths: args.paths,\n _: args._,\n base: args.base,\n config: args.config\n });\n }\n});\n","import { defineCommand } from 'citty';\nimport { configCommand } from '@/commands/config/index.ts';\nimport { diffCommand } from '@/commands/diff.ts';\nimport { runTui, tuiCommand } from '@/commands/tui.ts';\n\nconst SUBCOMMANDS = new Set(['tui', 'diff', 'config']);\n\nexport const rootCommand = defineCommand({\n meta: {\n name: 'envprism',\n description:\n 'TUI-based env file manager — refract one set of variables into many environment views.'\n },\n subCommands: {\n tui: tuiCommand,\n diff: diffCommand,\n config: configCommand\n },\n // citty 0.1.6 invokes the root `run` after a matched subcommand returns,\n // so guard against double-execution by bailing when the first positional\n // arg names a known subcommand. With no args at all we launch the TUI in\n // the cwd, which is the documented default.\n async run({ rawArgs }) {\n const firstPositional = rawArgs.find((a) => !a.startsWith('-'));\n if (firstPositional && SUBCOMMANDS.has(firstPositional)) return;\n await runTui({});\n }\n});\n","import { runMain } from 'citty';\nimport { rootCommand } from '@/cli.ts';\n\nrunMain(rootCommand);\n"],"mappings":";;;;;;;;;AAMA,IAAa,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6C/B,IAAa,c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,IAAI,mBAAmB,YAAY,IAAI,eAAe,GAAG;EACzD,MAAM,OAAO,CAAC,CAAC;CACjB;AACF,CAAC;;ACxBD,QAAQ,WAAW"}
@@ -1,9 +1,9 @@
1
- import { d as resolveThemeHex, f as findKvEntry, g as DEFAULT_CONFIG, h as truncate, l as DEFAULT_THEME_HEX, m as matchesFilter, p as formatValue, t as buildMatrix, u as resolveHeuristics } from "./matrix-CG1Msljr.mjs";
2
- import { n as serializeEnv, t as rebuildKvLine } from "./serialize-DWF9VxrS.mjs";
1
+ import { d as resolveThemeHex, f as findKvEntry, g as DEFAULT_CONFIG, h as truncate, l as DEFAULT_THEME_HEX, m as matchesFilter, p as formatValue, t as buildMatrix, u as resolveHeuristics } from "./matrix-CiLpV5eV.mjs";
2
+ import { n as serializeEnv, t as rebuildKvLine } from "./serialize-B280a9BO.mjs";
3
3
  import { writeFile } from "node:fs/promises";
4
4
  import { basename, dirname, join } from "pathe";
5
5
  import { BoxRenderable, RGBA, ScrollBoxRenderable, TextRenderable, createCliRenderer } from "@opentui/core";
6
- //#region src/tui/grouping.ts
6
+ // src/tui/grouping.ts
7
7
  var SECTION_COLLAPSE_KEY = "__other__";
8
8
  function prefixSection(key) {
9
9
  const idx = key.indexOf("_");
@@ -94,8 +94,7 @@ function keyDrifts(matrix, key) {
94
94
  }
95
95
  return false;
96
96
  }
97
- //#endregion
98
- //#region src/tui/envfile.ts
97
+ // src/tui/envfile.ts
99
98
  function isValidEnvFileName(name) {
100
99
  if (!name.startsWith(".env")) return false;
101
100
  if (name.includes("/") || name.includes("\\")) return false;
@@ -128,8 +127,7 @@ function appendKv(file, key, value) {
128
127
  file.trailingNewline = true;
129
128
  return entry;
130
129
  }
131
- //#endregion
132
- //#region src/tui/state/visible.ts
130
+ // src/tui/state/visible.ts
133
131
  function cellKey(key, file) {
134
132
  return `${key}|${file.path}`;
135
133
  }
@@ -198,8 +196,7 @@ function rebuildMatrix(ctx) {
198
196
  if (state.sidebarIdx >= ctx.allFiles.length) state.sidebarIdx = Math.max(0, ctx.allFiles.length - 1);
199
197
  recomputeVisibleKeys(ctx);
200
198
  }
201
- //#endregion
202
- //#region src/tui/actions/batch.ts
199
+ // src/tui/actions/batch.ts
203
200
  function applyToAllFiles(ctx, key, value) {
204
201
  const { state } = ctx;
205
202
  let touched = 0;
@@ -273,7 +270,6 @@ function undo(ctx) {
273
270
  last.file.entries.splice(last.idx, 0, last.entry);
274
271
  state.dirty.add(last.file);
275
272
  state.message = `Undid delete of ${last.entry.key} in ${basename(last.file.path)}.`;
276
- break;
277
273
  }
278
274
  rebuildMatrix(ctx);
279
275
  ctx.refresh();
@@ -313,8 +309,7 @@ function setBase(ctx) {
313
309
  state.message = wasDisabled ? `${basename(file.path)} is now the base (re-enabled).` : `${basename(file.path)} is now the base.`;
314
310
  ctx.refresh();
315
311
  }
316
- //#endregion
317
- //#region src/tui/actions/io.ts
312
+ // src/tui/actions/io.ts
318
313
  async function saveDirty(ctx) {
319
314
  const { state } = ctx;
320
315
  if (state.dirty.size === 0) {
@@ -336,11 +331,9 @@ async function saveDirty(ctx) {
336
331
  } else state.message = `Save failed: ${errors.join("; ")}`;
337
332
  ctx.refresh();
338
333
  }
339
- //#endregion
340
- //#region src/tui/types.ts
334
+ // src/tui/types.ts
341
335
  var KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
342
- //#endregion
343
- //#region src/tui/actions/prompt.ts
336
+ // src/tui/actions/prompt.ts
344
337
  function openPrompt(ctx, prompt, value = "") {
345
338
  const { state } = ctx;
346
339
  state.prompt = prompt;
@@ -510,8 +503,7 @@ function commitPrompt(ctx) {
510
503
  return;
511
504
  }
512
505
  }
513
- //#endregion
514
- //#region src/tui/keys/browse.ts
506
+ // src/tui/keys/browse.ts
515
507
  function handleBrowseKey(ctx, key, cleanup) {
516
508
  const { state } = ctx;
517
509
  const refresh = ctx.refresh;
@@ -643,8 +635,7 @@ function handleBrowseKey(ctx, key, cleanup) {
643
635
  refresh();
644
636
  }
645
637
  }
646
- //#endregion
647
- //#region src/tui/keys/filter.ts
638
+ // src/tui/keys/filter.ts
648
639
  function handleFilterKey(ctx, key) {
649
640
  const { state } = ctx;
650
641
  if (key.name === "escape") {
@@ -674,16 +665,14 @@ function handleFilterKey(ctx, key) {
674
665
  ctx.refresh();
675
666
  }
676
667
  }
677
- //#endregion
678
- //#region src/tui/keys/help.ts
668
+ // src/tui/keys/help.ts
679
669
  function handleHelpKey(ctx, key) {
680
670
  if (key.name === "escape" || key.sequence === "?" || key.sequence === "ß" || key.name === "q") {
681
671
  ctx.state.helpOpen = false;
682
672
  ctx.refresh();
683
673
  }
684
674
  }
685
- //#endregion
686
- //#region src/tui/keys/prompt.ts
675
+ // src/tui/keys/prompt.ts
687
676
  function handlePromptKey(ctx, key) {
688
677
  const { state } = ctx;
689
678
  if (key.name === "escape") {
@@ -721,8 +710,7 @@ function handlePromptKey(ctx, key) {
721
710
  ctx.refresh();
722
711
  }
723
712
  }
724
- //#endregion
725
- //#region src/tui/keys/onKey.ts
713
+ // src/tui/keys/onKey.ts
726
714
  /**
727
715
  * Build the global keypress handler. Dispatches by current mode; `cleanup`
728
716
  * tears down the renderer and resolves the run promise (used by Ctrl-C and
@@ -736,8 +724,7 @@ function createOnKey(ctx, cleanup) {
736
724
  handleBrowseKey(ctx, key, cleanup);
737
725
  };
738
726
  }
739
- //#endregion
740
- //#region src/tui/render/layout.ts
727
+ // src/tui/render/layout.ts
741
728
  /**
742
729
  * Build the static element tree once and return stable handles. Content is
743
730
  * (re)populated later by the refreshers; this only establishes the layout
@@ -775,8 +762,7 @@ function buildLayout(renderer, theme, layout) {
775
762
  title: "",
776
763
  flexDirection: "column",
777
764
  flexGrow: 1,
778
- paddingX: 1,
779
- paddingBottom: 1
765
+ paddingX: 1
780
766
  });
781
767
  body.add(matrixBox);
782
768
  const headerHost = new BoxRenderable(renderer, {
@@ -959,8 +945,7 @@ function buildLayout(renderer, theme, layout) {
959
945
  dimOverlay
960
946
  };
961
947
  }
962
- //#endregion
963
- //#region src/tui/render/filter.ts
948
+ // src/tui/render/filter.ts
964
949
  function refreshFilter(ctx) {
965
950
  const { el: { filterBox, filterField, filterStatus }, matrix, state } = ctx;
966
951
  const open = state.mode === "filter";
@@ -971,14 +956,12 @@ function refreshFilter(ctx) {
971
956
  const total = matrix.keys.length;
972
957
  filterStatus.content = state.filter.length === 0 ? "Type to filter the keys list." : `Matching ${matches} of ${total} keys.`;
973
958
  }
974
- //#endregion
975
- //#region src/tui/render/dom.ts
959
+ // src/tui/render/dom.ts
976
960
  function removeAllChildren(node) {
977
961
  const children = [...node.getChildren()];
978
962
  for (const child of children) node.remove(child);
979
963
  }
980
- //#endregion
981
- //#region src/tui/render/footer.ts
964
+ // src/tui/render/footer.ts
982
965
  function bindings(specs, theme) {
983
966
  const out = [];
984
967
  specs.forEach((spec, i) => {
@@ -1172,8 +1155,7 @@ function refreshFooter(ctx) {
1172
1155
  }
1173
1156
  status.content = state.message ?? "";
1174
1157
  }
1175
- //#endregion
1176
- //#region src/tui/help.ts
1158
+ // src/tui/help.ts
1177
1159
  function buildHelpLines() {
1178
1160
  return [
1179
1161
  {
@@ -1348,8 +1330,7 @@ function buildHelpLines() {
1348
1330
  }
1349
1331
  ];
1350
1332
  }
1351
- //#endregion
1352
- //#region src/tui/render/builders.ts
1333
+ // src/tui/render/builders.ts
1353
1334
  function buildValueCell(cell, secret, width, focused, modified, theme, isPlaceholder) {
1354
1335
  const bg = focused ? theme.focusBg : void 0;
1355
1336
  const trailing = modified ? {
@@ -1603,8 +1584,7 @@ function buildRow(renderer, idPrefix, cells, padX) {
1603
1584
  });
1604
1585
  return row;
1605
1586
  }
1606
- //#endregion
1607
- //#region src/tui/render/help.ts
1587
+ // src/tui/render/help.ts
1608
1588
  function refreshHelp(ctx) {
1609
1589
  const { el: { helpBox }, renderer, state, theme } = ctx;
1610
1590
  helpBox.visible = state.helpOpen;
@@ -1658,8 +1638,7 @@ function refreshHelp(ctx) {
1658
1638
  grid.add(right);
1659
1639
  helpBox.add(grid);
1660
1640
  }
1661
- //#endregion
1662
- //#region src/tui/render/matrix.ts
1641
+ // src/tui/render/matrix.ts
1663
1642
  function matrixTitle(matrix, state) {
1664
1643
  const visible = state.visibleKeys.length;
1665
1644
  const total = matrix.keys.length;
@@ -1740,8 +1719,7 @@ function refreshMatrix(ctx) {
1740
1719
  });
1741
1720
  }
1742
1721
  }
1743
- //#endregion
1744
- //#region src/tui/render/prompt.ts
1722
+ // src/tui/render/prompt.ts
1745
1723
  function promptLabelText(p) {
1746
1724
  switch (p.kind) {
1747
1725
  case "edit": return ` Edit ${p.key} in ${basename(p.file.path)}:`;
@@ -1814,8 +1792,7 @@ function refreshPrompt(ctx) {
1814
1792
  }
1815
1793
  }
1816
1794
  }
1817
- //#endregion
1818
- //#region src/tui/render/sidebar.ts
1795
+ // src/tui/render/sidebar.ts
1819
1796
  function refreshSidebar(ctx) {
1820
1797
  const { el: { sidebar }, renderer, matrix, allFiles, state, theme } = ctx;
1821
1798
  const total = allFiles.length;
@@ -1854,8 +1831,7 @@ function refreshSidebar(ctx) {
1854
1831
  sidebar.add(row);
1855
1832
  }
1856
1833
  }
1857
- //#endregion
1858
- //#region src/tui/render/index.ts
1834
+ // src/tui/render/index.ts
1859
1835
  /**
1860
1836
  * Full synchronous render of every region. Reads `ctx.matrix` fresh so a
1861
1837
  * `rebuildMatrix` that ran between scheduling and this flush is reflected.
@@ -1870,8 +1846,7 @@ function refreshAll(ctx) {
1870
1846
  refreshFilter(ctx);
1871
1847
  ctx.el.dimOverlay.visible = state.helpOpen || state.mode === "prompt" || state.mode === "filter";
1872
1848
  }
1873
- //#endregion
1874
- //#region src/tui/theme.ts
1849
+ // src/tui/theme.ts
1875
1850
  /** Resolve a partial hex theme into RGBA values (gaps + invalid → defaults). */
1876
1851
  function resolveTheme(theme = {}, warn) {
1877
1852
  const hex = resolveThemeHex(theme, warn);
@@ -1889,8 +1864,7 @@ function resolveLayout(layout) {
1889
1864
  CELL_PAD_X: layout.cellPadX
1890
1865
  };
1891
1866
  }
1892
- //#endregion
1893
- //#region src/tui/app.ts
1867
+ // src/tui/app.ts
1894
1868
  async function runMatrixTui(initialMatrix, config = DEFAULT_CONFIG) {
1895
1869
  const renderer = await createCliRenderer({ useMouse: true });
1896
1870
  const theme = resolveTheme(config.tui.theme);
@@ -1959,7 +1933,6 @@ async function runMatrixTui(initialMatrix, config = DEFAULT_CONFIG) {
1959
1933
  renderer.on("resize", ctx.refresh);
1960
1934
  });
1961
1935
  }
1962
- //#endregion
1963
1936
  export { runMatrixTui };
1964
1937
 
1965
- //# sourceMappingURL=app-Bp7QXiLx.mjs.map
1938
+ //# sourceMappingURL=app-BqQuZiRW.mjs.map