@visulima/vis 1.0.0-alpha.1 → 1.0.0-alpha.11

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.
Files changed (120) hide show
  1. package/CHANGELOG.md +403 -12
  2. package/LICENSE.md +283 -0
  3. package/README.md +254 -9
  4. package/dist/bin.js +9 -146
  5. package/dist/config/index.d.ts +1818 -0
  6. package/dist/config/index.js +2 -0
  7. package/dist/generate/index.d.ts +157 -0
  8. package/dist/generate/index.js +3 -0
  9. package/dist/packem_chunks/applyDefaults.js +336 -0
  10. package/dist/packem_chunks/bin.js +9577 -0
  11. package/dist/packem_chunks/doctor-probe.js +112 -0
  12. package/dist/packem_chunks/fix.js +234 -0
  13. package/dist/packem_chunks/handler.js +99 -0
  14. package/dist/packem_chunks/handler10.js +53 -0
  15. package/dist/packem_chunks/handler11.js +32 -0
  16. package/dist/packem_chunks/handler12.js +100 -0
  17. package/dist/packem_chunks/handler13.js +25 -0
  18. package/dist/packem_chunks/handler14.js +916 -0
  19. package/dist/packem_chunks/handler15.js +206 -0
  20. package/dist/packem_chunks/handler16.js +124 -0
  21. package/dist/packem_chunks/handler17.js +13 -0
  22. package/dist/packem_chunks/handler18.js +106 -0
  23. package/dist/packem_chunks/handler19.js +19 -0
  24. package/dist/packem_chunks/handler2.js +75 -0
  25. package/dist/packem_chunks/handler20.js +29 -0
  26. package/dist/packem_chunks/handler21.js +222 -0
  27. package/dist/packem_chunks/handler22.js +237 -0
  28. package/dist/packem_chunks/handler23.js +101 -0
  29. package/dist/packem_chunks/handler24.js +110 -0
  30. package/dist/packem_chunks/handler25.js +402 -0
  31. package/dist/packem_chunks/handler26.js +13 -0
  32. package/dist/packem_chunks/handler27.js +63 -0
  33. package/dist/packem_chunks/handler28.js +34 -0
  34. package/dist/packem_chunks/handler29.js +458 -0
  35. package/dist/packem_chunks/handler3.js +95 -0
  36. package/dist/packem_chunks/handler30.js +170 -0
  37. package/dist/packem_chunks/handler31.js +530 -0
  38. package/dist/packem_chunks/handler32.js +214 -0
  39. package/dist/packem_chunks/handler33.js +119 -0
  40. package/dist/packem_chunks/handler34.js +630 -0
  41. package/dist/packem_chunks/handler35.js +283 -0
  42. package/dist/packem_chunks/handler36.js +542 -0
  43. package/dist/packem_chunks/handler37.js +762 -0
  44. package/dist/packem_chunks/handler38.js +989 -0
  45. package/dist/packem_chunks/handler39.js +574 -0
  46. package/dist/packem_chunks/handler4.js +90 -0
  47. package/dist/packem_chunks/handler40.js +1685 -0
  48. package/dist/packem_chunks/handler41.js +1088 -0
  49. package/dist/packem_chunks/handler42.js +797 -0
  50. package/dist/packem_chunks/handler43.js +2658 -0
  51. package/dist/packem_chunks/handler44.js +3886 -0
  52. package/dist/packem_chunks/handler45.js +2574 -0
  53. package/dist/packem_chunks/handler46.js +3769 -0
  54. package/dist/packem_chunks/handler47.js +1491 -0
  55. package/dist/packem_chunks/handler5.js +174 -0
  56. package/dist/packem_chunks/handler6.js +95 -0
  57. package/dist/packem_chunks/handler7.js +115 -0
  58. package/dist/packem_chunks/handler8.js +12 -0
  59. package/dist/packem_chunks/handler9.js +29 -0
  60. package/dist/packem_chunks/heal-accept.js +522 -0
  61. package/dist/packem_chunks/heal.js +673 -0
  62. package/dist/packem_chunks/index.js +873 -0
  63. package/dist/packem_chunks/loader.js +23 -0
  64. package/dist/packem_shared/VisUpdateApp-D-Yz_wvg.js +1316 -0
  65. package/dist/packem_shared/_commonjsHelpers-BqLXS_qQ.js +5 -0
  66. package/dist/packem_shared/ai-analysis-CHeB1joD.js +367 -0
  67. package/dist/packem_shared/ai-cache-Be_jexe4.js +142 -0
  68. package/dist/packem_shared/ai-fix-B9iQVcD2.js +379 -0
  69. package/dist/packem_shared/cache-directory-2qvs4goY.js +98 -0
  70. package/dist/packem_shared/catalog-BJTtyi-O.js +1371 -0
  71. package/dist/packem_shared/dependency-scan-A0KSklpG.js +188 -0
  72. package/dist/packem_shared/docker-2iZzc280.js +181 -0
  73. package/dist/packem_shared/failure-log-Cz3Z4SKL.js +100 -0
  74. package/dist/packem_shared/flakiness-goTxXuCX.js +180 -0
  75. package/dist/packem_shared/otel-DCvqCTz_.js +158 -0
  76. package/dist/packem_shared/otelPlugin-DFaLDvJf.js +3 -0
  77. package/dist/packem_shared/registry-CbqXI0rc.js +272 -0
  78. package/dist/packem_shared/run-summary-utils-PVMl4aIh.js +130 -0
  79. package/dist/packem_shared/runtime-check-Cobi3p6l.js +127 -0
  80. package/dist/packem_shared/selectors-SM69TfqC.js +194 -0
  81. package/dist/packem_shared/symbols-Ta7g2nU-.js +14 -0
  82. package/dist/packem_shared/toolchain-BdZd9eBi.js +975 -0
  83. package/dist/packem_shared/typosquats-C-bCh3PX.js +1210 -0
  84. package/dist/packem_shared/use-measured-height-CNP0vT4M.js +20 -0
  85. package/dist/packem_shared/utils-CthVdBPS.js +40 -0
  86. package/dist/packem_shared/xxh3-Ck8mXNg1.js +239 -0
  87. package/index.js +773 -0
  88. package/package.json +82 -21
  89. package/schemas/project.schema.json +420 -0
  90. package/schemas/vis-config.schema.json +501 -0
  91. package/skills/vis/SKILL.md +96 -0
  92. package/templates/buildkite-ci/.buildkite/pipeline.yml.tera +85 -0
  93. package/templates/buildkite-ci/template.yml +20 -0
  94. package/dist/ai-analysis.d.ts +0 -40
  95. package/dist/ai-cache.d.ts +0 -21
  96. package/dist/bin.d.ts +0 -1
  97. package/dist/catalog.d.ts +0 -110
  98. package/dist/commands/affected.d.ts +0 -3
  99. package/dist/commands/ai.d.ts +0 -3
  100. package/dist/commands/analyze.d.ts +0 -3
  101. package/dist/commands/check.d.ts +0 -3
  102. package/dist/commands/graph.d.ts +0 -3
  103. package/dist/commands/hook/constants.d.ts +0 -8
  104. package/dist/commands/hook/index.d.ts +0 -3
  105. package/dist/commands/hook/install.d.ts +0 -7
  106. package/dist/commands/hook/migrate.d.ts +0 -27
  107. package/dist/commands/hook/uninstall.d.ts +0 -3
  108. package/dist/commands/migrate/constants.d.ts +0 -12
  109. package/dist/commands/migrate/deps.d.ts +0 -32
  110. package/dist/commands/migrate/index.d.ts +0 -3
  111. package/dist/commands/migrate/json.d.ts +0 -20
  112. package/dist/commands/migrate/lint-staged.d.ts +0 -62
  113. package/dist/commands/migrate/types.d.ts +0 -20
  114. package/dist/commands/run.d.ts +0 -3
  115. package/dist/commands/staged.d.ts +0 -3
  116. package/dist/commands/update.d.ts +0 -3
  117. package/dist/config.d.ts +0 -40
  118. package/dist/config.js +0 -1
  119. package/dist/package-manager.d.ts +0 -23
  120. package/dist/workspace.d.ts +0 -58
@@ -0,0 +1,2 @@
1
+ export { CONFIG_FILES, SECURITY_DEFAULTS, TASK_CONFIG_FILES, applyDefaults, defineConfig, definePlugin, defineTaskConfig, findVisConfigFile, findVisTaskConfigFile, loadVisConfig, loadVisTaskConfig } from '../packem_chunks/applyDefaults.js';
2
+ export { o as otelPlugin } from '../packem_shared/otel-DCvqCTz_.js';
@@ -0,0 +1,157 @@
1
+ /**
2
+ * Type definitions for the `vis generate` template runtime.
3
+ *
4
+ * The shape intentionally echoes Bingo's `Template` so a future Bingo
5
+ * adapter (re-exporting `bingo` Templates through this runtime) is a
6
+ * one-pager. Authors do not depend on Bingo to write a vis generator.
7
+ */
8
+ type VariableType = "array" | "boolean" | "enum" | "number" | "string";
9
+ /** Common variable fields (all types). */
10
+ interface VariableBase {
11
+ /**
12
+ * Default value when the user accepts the prompt without typing.
13
+ * For `boolean` this is `true|false`; for `enum` it must match `values`.
14
+ */
15
+ default?: boolean | number | string | string[];
16
+ /** Hide from prompts; can still be set via CLI or `--defaults`. */
17
+ internal?: boolean;
18
+ /** Sort order in prompts (lower first). Defaults to declaration order. */
19
+ order?: number;
20
+ /** Override the prompt text. Defaults to the variable name. */
21
+ prompt?: string;
22
+ /** When true, the user must provide a non-empty value. */
23
+ required?: boolean;
24
+ }
25
+ type StringVariable = VariableBase & {
26
+ type: "string";
27
+ };
28
+ type NumberVariable = VariableBase & {
29
+ type: "number";
30
+ };
31
+ type BooleanVariable = VariableBase & {
32
+ default?: boolean;
33
+ type: "boolean";
34
+ };
35
+ type ArrayVariable = VariableBase & {
36
+ type: "array";
37
+ };
38
+ interface EnumVariable extends VariableBase {
39
+ /** Allow multiple selections (returns `string[]`). */
40
+ multiple?: boolean;
41
+ type: "enum";
42
+ /** Selectable values. */
43
+ values: string[];
44
+ }
45
+ type Variable = ArrayVariable | BooleanVariable | EnumVariable | NumberVariable | StringVariable;
46
+ /** Map of variable name → spec, as authors declare them. */
47
+ type VariableMap = Record<string, Variable>;
48
+ /** Resolved option values passed to `produce()`. */
49
+ type Options = Record<string, unknown>;
50
+ /** A file in a Creation can be a string, a Buffer (binary asset), or a nested directory. */
51
+ type CreationFile = Buffer | string;
52
+ interface CreationDirectory {
53
+ [key: string]: CreationDirectory | CreationFile;
54
+ }
55
+ /**
56
+ * Script entry produced by `produce()`.
57
+ * - `string`: shell command, runs in the destination directory.
58
+ * - `object`: shell commands with optional phase ordering.
59
+ */
60
+ type Script = ScriptObject | string;
61
+ interface ScriptObject {
62
+ /** Shell command(s) to run sequentially. */
63
+ commands: string[];
64
+ /**
65
+ * Phase ordering. Phases run in ascending order; scripts within
66
+ * the same phase are dispatched concurrently. Default: 0.
67
+ */
68
+ phase?: number;
69
+ /** Suppress command output. Default: false. */
70
+ silent?: boolean;
71
+ }
72
+ /** Object returned by a template's `produce()` function. */
73
+ interface Creation {
74
+ /** Recursive directory tree. Keys with `/` are auto-split. */
75
+ files?: CreationDirectory;
76
+ /**
77
+ * Per-file metadata keyed by the *flattened* destination path
78
+ * (e.g. `src/foo.ts`). Optional — native templates usually omit
79
+ * this; the moon adapter populates it from per-file frontmatter
80
+ * so `force: true` survives the trip to the runner without
81
+ * changing the shape of `files`.
82
+ */
83
+ filesMeta?: Record<string, FileMeta>;
84
+ /** Shell scripts to run after files are written. */
85
+ scripts?: Script[];
86
+ /** User-facing tips printed after the run. */
87
+ suggestions?: string[];
88
+ }
89
+ interface FileMeta {
90
+ /**
91
+ * Overwrite an existing file at this path without prompting or
92
+ * consulting the global `--force` flag.
93
+ */
94
+ force?: boolean;
95
+ }
96
+ /** Context object passed to `produce()`. */
97
+ interface TemplateContext {
98
+ /** Built-in variables: `dest_dir`, `dest_rel_dir`, `working_dir`, `workspace_root`. */
99
+ builtins: BuiltinVars;
100
+ /** Resolved option values (after prompts + CLI overrides + defaults). */
101
+ options: Options;
102
+ }
103
+ interface BuiltinVars {
104
+ /** Absolute destination directory. */
105
+ dest_dir: string;
106
+ /** Destination relative to the workspace root. */
107
+ dest_rel_dir: string;
108
+ /** Caller's current working directory. */
109
+ working_dir: string;
110
+ /** Absolute workspace root (from `findMonorepoRootSync`, fallback to `working_dir`). */
111
+ workspace_root: string;
112
+ }
113
+ /** Top-level "About" metadata for a template. */
114
+ interface TemplateAbout {
115
+ /** One-line description. */
116
+ description: string;
117
+ /** Short identifier shown in `vis generate --list` and prompts. */
118
+ name: string;
119
+ }
120
+ /**
121
+ * The author-facing template shape.
122
+ * Both native (`.vis/templates/&lt;name>.ts`) and moon-adapter outputs
123
+ * normalize to this.
124
+ */
125
+ interface Template {
126
+ about: TemplateAbout;
127
+ /**
128
+ * Default destination directory (relative to workspace root unless
129
+ * absolute or starting with `./`). Honored when the user does not
130
+ * pass `--to`. Maps to moon's `template.yml` `destination`.
131
+ */
132
+ destination?: string;
133
+ /** Variable schema for prompts. */
134
+ options?: VariableMap;
135
+ /** Build the Creation given resolved options and built-in vars. */
136
+ produce: (context: TemplateContext) => Creation | Promise<Creation>;
137
+ }
138
+ /**
139
+ * Discovery record: a Template plus where it came from.
140
+ * Surfaced by `vis generate --list`.
141
+ */
142
+ interface DiscoveredTemplate {
143
+ /** Lazy loader — invoke to materialize the Template. */
144
+ load: () => Promise<Template>;
145
+ /** Stable name used by `vis generate &lt;name>`. */
146
+ name: string;
147
+ /** Absolute path on disk (file for native, directory for moon). */
148
+ path: string;
149
+ /** Source classification — affects load + listing. */
150
+ source: "builtin" | "config" | "moon" | "native" | "remote";
151
+ }
152
+ /**
153
+ * Identity helper for type inference. Authors get autocomplete + checks
154
+ * without having to annotate the export.
155
+ */
156
+ declare const createTemplate: (template: Template) => Template;
157
+ export { type ArrayVariable, type BooleanVariable, type BuiltinVars, type Creation, type CreationDirectory, type CreationFile, type DiscoveredTemplate, type EnumVariable, type FileMeta, type NumberVariable, type Options, type Script, type ScriptObject, type StringVariable, type Template, type TemplateAbout, type TemplateContext, type Variable, type VariableMap, type VariableType, createTemplate };
@@ -0,0 +1,3 @@
1
+ const createTemplate = (template) => template;
2
+
3
+ export { createTemplate };
@@ -0,0 +1,336 @@
1
+ import { createRequire as __cjs_createRequire } from "node:module";
2
+
3
+ const __cjs_require = __cjs_createRequire(import.meta.url);
4
+
5
+ const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
6
+
7
+ const __cjs_getBuiltinModule = (module) => {
8
+ // Check if we're in Node.js and version supports getBuiltinModule
9
+ if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
10
+ const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
11
+ // Node.js 20.16.0+ and 22.3.0+
12
+ if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
13
+ return __cjs_getProcess.getBuiltinModule(module);
14
+ }
15
+ }
16
+ // Fallback to createRequire
17
+ return __cjs_require(module);
18
+ };
19
+
20
+ const {
21
+ createHash
22
+ } = __cjs_getBuiltinModule("node:crypto");
23
+ const {
24
+ readdirSync,
25
+ copyFileSync,
26
+ unlinkSync,
27
+ readFileSync
28
+ } = __cjs_getBuiltinModule("node:fs");
29
+ const {
30
+ createRequire
31
+ } = __cjs_getBuiltinModule("node:module");
32
+ const {
33
+ tmpdir
34
+ } = __cjs_getBuiltinModule("node:os");
35
+ import { findCacheDirSync } from '@visulima/find-cache-dir';
36
+ import { isAccessibleSync, ensureDirSync, readJsonSync, writeJsonSync } from '@visulima/fs';
37
+ import { join, dirname, isAbsolute } from '@visulima/path';
38
+ import { createJiti } from 'jiti';
39
+ import { V as VisConfigCycleError, m as mergeTargetWithInherit, a as VisConfigLoadError, b as VisConfigNotFoundError } from '../packem_shared/otel-DCvqCTz_.js';
40
+ export { o as otelPlugin } from '../packem_shared/otel-DCvqCTz_.js';
41
+
42
+ const CONFIG_FILES = ["vis.config.ts", "vis.config.mts", "vis.config.cts", "vis.config.js", "vis.config.mjs", "vis.config.cjs"];
43
+ const CONFIG_FILE_SET = new Set(CONFIG_FILES);
44
+ const TASK_CONFIG_FILES = ["vis.task.ts", "vis.task.mts", "vis.task.cts", "vis.task.js", "vis.task.mjs", "vis.task.cjs"];
45
+ const TASK_CONFIG_FILE_SET = new Set(TASK_CONFIG_FILES);
46
+ const SECURITY_DEFAULTS = {
47
+ /** Block transitive dependencies from using git repos or tarball URLs. */
48
+ blockExoticSubdeps: true,
49
+ /** Make unapproved build scripts a hard error instead of a warning. */
50
+ strictDepBuilds: true,
51
+ /** Fail if a package's trust level has decreased compared to prior releases. */
52
+ trustPolicy: "no-downgrade",
53
+ /** Skip trust policy check for packages published more than 30 days ago. */
54
+ trustPolicyIgnoreAfter: 43200
55
+ };
56
+ const mergeSecurityDefaults = (security) => {
57
+ return {
58
+ ...SECURITY_DEFAULTS,
59
+ ...security
60
+ };
61
+ };
62
+ const applyDefaults = (config) => {
63
+ return {
64
+ ...config,
65
+ security: mergeSecurityDefaults(config.security),
66
+ update: {
67
+ security: true,
68
+ target: "minor",
69
+ ...config.update
70
+ }
71
+ };
72
+ };
73
+ const findVisConfigFile = (directory) => {
74
+ let entries;
75
+ try {
76
+ entries = readdirSync(directory);
77
+ } catch {
78
+ return void 0;
79
+ }
80
+ const present = new Set(entries.filter((name) => CONFIG_FILE_SET.has(name)));
81
+ for (const file of CONFIG_FILES) {
82
+ if (present.has(file)) {
83
+ return join(directory, file);
84
+ }
85
+ }
86
+ return void 0;
87
+ };
88
+ const findVisTaskConfigFile = (projectDirectory) => {
89
+ let entries;
90
+ try {
91
+ entries = readdirSync(projectDirectory);
92
+ } catch {
93
+ return void 0;
94
+ }
95
+ const present = new Set(entries.filter((name) => TASK_CONFIG_FILE_SET.has(name)));
96
+ for (const file of TASK_CONFIG_FILES) {
97
+ if (present.has(file)) {
98
+ return join(projectDirectory, file);
99
+ }
100
+ }
101
+ return void 0;
102
+ };
103
+ const hashFileContents = (filePath) => createHash("sha256").update(readFileSync(filePath)).digest("hex");
104
+ const hashConfigChain = (paths) => {
105
+ const hasher = createHash("sha256");
106
+ const sorted = [...paths].sort();
107
+ for (const path of sorted) {
108
+ hasher.update(path);
109
+ hasher.update(":");
110
+ hasher.update(hashFileContents(path));
111
+ hasher.update("\n");
112
+ }
113
+ return hasher.digest("hex");
114
+ };
115
+ const getConfigCachePath = (workspaceRoot) => {
116
+ const nodeModulesDir = join(workspaceRoot, "node_modules");
117
+ if (isAccessibleSync(nodeModulesDir)) {
118
+ const directCacheDir = join(nodeModulesDir, ".cache", "vis");
119
+ ensureDirSync(directCacheDir);
120
+ return join(directCacheDir, "vis-config-cache.json");
121
+ }
122
+ const cacheDir = findCacheDirSync("vis", { create: true, cwd: workspaceRoot });
123
+ return cacheDir ? join(cacheDir, "vis-config-cache.json") : void 0;
124
+ };
125
+ const readConfigCache = (cachePath, hash) => {
126
+ if (!isAccessibleSync(cachePath)) {
127
+ return void 0;
128
+ }
129
+ try {
130
+ const cache = readJsonSync(cachePath);
131
+ if (cache.hash === hash) {
132
+ return cache.config;
133
+ }
134
+ } catch {
135
+ }
136
+ return void 0;
137
+ };
138
+ const writeConfigCache = (cachePath, hash, config) => {
139
+ try {
140
+ ensureDirSync(dirname(cachePath));
141
+ writeJsonSync(cachePath, { config, hash });
142
+ } catch {
143
+ }
144
+ };
145
+ const normalizeExtends = (value) => {
146
+ if (value === void 0) {
147
+ return [];
148
+ }
149
+ return Array.isArray(value) ? value : [value];
150
+ };
151
+ const resolveExtendsSpecifier = (specifier, parentFile, chain) => {
152
+ if (isAbsolute(specifier)) {
153
+ throw new VisConfigNotFoundError(
154
+ specifier,
155
+ [...chain, parentFile],
156
+ ["Absolute paths in `extends` are not supported. Use a relative path or an npm package name."]
157
+ );
158
+ }
159
+ const attempted = [];
160
+ if (specifier.startsWith("./") || specifier.startsWith("../")) {
161
+ const parentDirectory = dirname(parentFile);
162
+ const resolved = join(parentDirectory, specifier);
163
+ attempted.push(resolved);
164
+ if (isAccessibleSync(resolved)) {
165
+ return resolved;
166
+ }
167
+ throw new VisConfigNotFoundError(specifier, [...chain, parentFile], attempted);
168
+ }
169
+ try {
170
+ const requireFromParent = createRequire(parentFile);
171
+ return requireFromParent.resolve(specifier);
172
+ } catch {
173
+ attempted.push(`require.resolve("${specifier}") from ${parentFile}`);
174
+ throw new VisConfigNotFoundError(specifier, [...chain, parentFile], attempted);
175
+ }
176
+ };
177
+ const loadRawConfig = async (jiti, configPath, chain) => {
178
+ const hash = hashFileContents(configPath);
179
+ const extension = configPath.slice(configPath.lastIndexOf("."));
180
+ const temporaryConfigPath = join(tmpdir(), `vis-config-${hash}${extension}`);
181
+ copyFileSync(configPath, temporaryConfigPath);
182
+ let loaded;
183
+ try {
184
+ loaded = await jiti.import(temporaryConfigPath, { default: true, try: true }) ?? {};
185
+ } catch (error) {
186
+ throw new VisConfigLoadError(configPath, chain, error);
187
+ } finally {
188
+ try {
189
+ unlinkSync(temporaryConfigPath);
190
+ } catch {
191
+ }
192
+ }
193
+ try {
194
+ return (typeof loaded === "function" ? await loaded() ?? {} : loaded) ?? {};
195
+ } catch (error) {
196
+ throw new VisConfigLoadError(configPath, chain, error);
197
+ }
198
+ };
199
+ const mergeVisConfigs = (parent, child) => {
200
+ const merged = { ...parent, ...child };
201
+ if (parent.targetDefaults || child.targetDefaults) {
202
+ const names = /* @__PURE__ */ new Set([...Object.keys(parent.targetDefaults ?? {}), ...Object.keys(child.targetDefaults ?? {})]);
203
+ const out = {};
204
+ for (const name of names) {
205
+ out[name] = mergeTargetWithInherit(parent.targetDefaults?.[name], child.targetDefaults?.[name]);
206
+ }
207
+ merged.targetDefaults = out;
208
+ }
209
+ if (parent.taskDefaults || child.taskDefaults) {
210
+ merged.taskDefaults = [...parent.taskDefaults ?? [], ...child.taskDefaults ?? []];
211
+ }
212
+ if (parent.fileGroups || child.fileGroups) {
213
+ merged.fileGroups = { ...parent.fileGroups, ...child.fileGroups };
214
+ }
215
+ if (parent.taskGroups || child.taskGroups) {
216
+ merged.taskGroups = { ...parent.taskGroups, ...child.taskGroups };
217
+ }
218
+ if (parent.security || child.security) {
219
+ merged.security = { ...parent.security, ...child.security };
220
+ }
221
+ if (parent.update || child.update) {
222
+ merged.update = { ...parent.update, ...child.update };
223
+ }
224
+ if (parent.taskRunnerOptions || child.taskRunnerOptions) {
225
+ merged.taskRunnerOptions = { ...parent.taskRunnerOptions, ...child.taskRunnerOptions };
226
+ }
227
+ delete merged.extends;
228
+ return merged;
229
+ };
230
+ const resolveConfigChain = async (jiti, configPath, chain, inFlight, loaded, order) => {
231
+ if (inFlight.has(configPath)) {
232
+ throw new VisConfigCycleError(configPath, chain);
233
+ }
234
+ if (loaded.has(configPath)) {
235
+ return;
236
+ }
237
+ inFlight.add(configPath);
238
+ try {
239
+ const raw = await loadRawConfig(jiti, configPath, chain);
240
+ const extendsList = normalizeExtends(raw.extends);
241
+ for (const specifier of extendsList) {
242
+ const resolved = resolveExtendsSpecifier(specifier, configPath, chain);
243
+ await resolveConfigChain(jiti, resolved, [...chain, configPath], inFlight, loaded, order);
244
+ }
245
+ loaded.set(configPath, raw);
246
+ order.push(configPath);
247
+ } finally {
248
+ inFlight.delete(configPath);
249
+ }
250
+ };
251
+ const loadVisConfig = async (workspaceRoot) => {
252
+ const rootConfigPath = findVisConfigFile(workspaceRoot);
253
+ if (!rootConfigPath) {
254
+ return applyDefaults({});
255
+ }
256
+ const jiti = createJiti(workspaceRoot, { fsCache: false, moduleCache: false });
257
+ const inFlight = /* @__PURE__ */ new Set();
258
+ const loaded = /* @__PURE__ */ new Map();
259
+ const order = [];
260
+ await resolveConfigChain(jiti, rootConfigPath, [], inFlight, loaded, order);
261
+ const chainHash = hashConfigChain(order);
262
+ const cachePath = getConfigCachePath(workspaceRoot);
263
+ if (cachePath) {
264
+ const cached = readConfigCache(cachePath, chainHash);
265
+ if (cached) {
266
+ return cached;
267
+ }
268
+ }
269
+ let merged = {};
270
+ for (const path of order) {
271
+ merged = mergeVisConfigs(merged, loaded.get(path));
272
+ }
273
+ const finalConfig = applyDefaults(merged);
274
+ if (cachePath) {
275
+ writeConfigCache(cachePath, chainHash, finalConfig);
276
+ }
277
+ return finalConfig;
278
+ };
279
+ const sanitizeProjectName = (projectName) => projectName.replaceAll(/[^\w.-]+/g, "_");
280
+ const getVisTaskCachePath = (workspaceRoot, projectName) => {
281
+ const nodeModulesDir = join(workspaceRoot, "node_modules");
282
+ const safeName = sanitizeProjectName(projectName);
283
+ if (isAccessibleSync(nodeModulesDir)) {
284
+ const directCacheDir = join(nodeModulesDir, ".cache", "vis", "task-configs");
285
+ ensureDirSync(directCacheDir);
286
+ return join(directCacheDir, `${safeName}.json`);
287
+ }
288
+ const cacheDir = findCacheDirSync("vis", { create: true, cwd: workspaceRoot });
289
+ return cacheDir ? join(cacheDir, "task-configs", `${safeName}.json`) : void 0;
290
+ };
291
+ const readVisTaskCache = (cachePath, hash) => {
292
+ if (!isAccessibleSync(cachePath)) {
293
+ return void 0;
294
+ }
295
+ try {
296
+ const cache = readJsonSync(cachePath);
297
+ if (cache.hash === hash) {
298
+ return cache.config;
299
+ }
300
+ } catch {
301
+ }
302
+ return void 0;
303
+ };
304
+ const writeVisTaskCache = (cachePath, hash, config) => {
305
+ try {
306
+ ensureDirSync(dirname(cachePath));
307
+ writeJsonSync(cachePath, { config, hash });
308
+ } catch {
309
+ }
310
+ };
311
+ const loadVisTaskConfig = async (workspaceRoot, projectDirectory, projectName) => {
312
+ const taskConfigPath = findVisTaskConfigFile(projectDirectory);
313
+ if (!taskConfigPath) {
314
+ return void 0;
315
+ }
316
+ const hash = hashFileContents(taskConfigPath);
317
+ const cachePath = getVisTaskCachePath(workspaceRoot, projectName);
318
+ if (cachePath) {
319
+ const cached = readVisTaskCache(cachePath, hash);
320
+ if (cached) {
321
+ return cached;
322
+ }
323
+ }
324
+ const jiti = createJiti(projectDirectory, { fsCache: false, moduleCache: false });
325
+ const raw = await loadRawConfig(jiti, taskConfigPath, []);
326
+ const taskConfig = raw;
327
+ if (cachePath) {
328
+ writeVisTaskCache(cachePath, hash, taskConfig);
329
+ }
330
+ return taskConfig;
331
+ };
332
+ const defineTaskConfig = (config) => config;
333
+ const defineConfig = (config) => applyDefaults(config);
334
+ const definePlugin = (plugin) => plugin;
335
+
336
+ export { CONFIG_FILES, SECURITY_DEFAULTS, TASK_CONFIG_FILES, applyDefaults, defineConfig, definePlugin, defineTaskConfig, findVisConfigFile, findVisTaskConfigFile, loadVisConfig, loadVisTaskConfig };