@domainlang/language 0.1.20

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 (212) hide show
  1. package/README.md +163 -0
  2. package/out/ast-augmentation.d.ts +6 -0
  3. package/out/ast-augmentation.js +2 -0
  4. package/out/ast-augmentation.js.map +1 -0
  5. package/out/domain-lang-module.d.ts +57 -0
  6. package/out/domain-lang-module.js +67 -0
  7. package/out/domain-lang-module.js.map +1 -0
  8. package/out/generated/ast.d.ts +759 -0
  9. package/out/generated/ast.js +556 -0
  10. package/out/generated/ast.js.map +1 -0
  11. package/out/generated/grammar.d.ts +6 -0
  12. package/out/generated/grammar.js +2407 -0
  13. package/out/generated/grammar.js.map +1 -0
  14. package/out/generated/module.d.ts +13 -0
  15. package/out/generated/module.js +21 -0
  16. package/out/generated/module.js.map +1 -0
  17. package/out/index.d.ts +16 -0
  18. package/out/index.js +22 -0
  19. package/out/index.js.map +1 -0
  20. package/out/lsp/domain-lang-code-actions.d.ts +55 -0
  21. package/out/lsp/domain-lang-code-actions.js +143 -0
  22. package/out/lsp/domain-lang-code-actions.js.map +1 -0
  23. package/out/lsp/domain-lang-completion.d.ts +37 -0
  24. package/out/lsp/domain-lang-completion.js +452 -0
  25. package/out/lsp/domain-lang-completion.js.map +1 -0
  26. package/out/lsp/domain-lang-formatter.d.ts +15 -0
  27. package/out/lsp/domain-lang-formatter.js +43 -0
  28. package/out/lsp/domain-lang-formatter.js.map +1 -0
  29. package/out/lsp/domain-lang-naming.d.ts +34 -0
  30. package/out/lsp/domain-lang-naming.js +49 -0
  31. package/out/lsp/domain-lang-naming.js.map +1 -0
  32. package/out/lsp/domain-lang-scope.d.ts +59 -0
  33. package/out/lsp/domain-lang-scope.js +102 -0
  34. package/out/lsp/domain-lang-scope.js.map +1 -0
  35. package/out/lsp/domain-lang-workspace-manager.d.ts +21 -0
  36. package/out/lsp/domain-lang-workspace-manager.js +93 -0
  37. package/out/lsp/domain-lang-workspace-manager.js.map +1 -0
  38. package/out/lsp/hover/ddd-pattern-explanations.d.ts +50 -0
  39. package/out/lsp/hover/ddd-pattern-explanations.js +196 -0
  40. package/out/lsp/hover/ddd-pattern-explanations.js.map +1 -0
  41. package/out/lsp/hover/domain-lang-hover.d.ts +19 -0
  42. package/out/lsp/hover/domain-lang-hover.js +302 -0
  43. package/out/lsp/hover/domain-lang-hover.js.map +1 -0
  44. package/out/lsp/hover/domain-lang-keywords.d.ts +13 -0
  45. package/out/lsp/hover/domain-lang-keywords.js +47 -0
  46. package/out/lsp/hover/domain-lang-keywords.js.map +1 -0
  47. package/out/lsp/manifest-diagnostics.d.ts +82 -0
  48. package/out/lsp/manifest-diagnostics.js +230 -0
  49. package/out/lsp/manifest-diagnostics.js.map +1 -0
  50. package/out/main-browser.d.ts +1 -0
  51. package/out/main-browser.js +11 -0
  52. package/out/main-browser.js.map +1 -0
  53. package/out/main.d.ts +1 -0
  54. package/out/main.js +74 -0
  55. package/out/main.js.map +1 -0
  56. package/out/sdk/ast-augmentation.d.ts +136 -0
  57. package/out/sdk/ast-augmentation.js +62 -0
  58. package/out/sdk/ast-augmentation.js.map +1 -0
  59. package/out/sdk/index.d.ts +94 -0
  60. package/out/sdk/index.js +97 -0
  61. package/out/sdk/index.js.map +1 -0
  62. package/out/sdk/indexes.d.ts +16 -0
  63. package/out/sdk/indexes.js +97 -0
  64. package/out/sdk/indexes.js.map +1 -0
  65. package/out/sdk/loader-node.d.ts +51 -0
  66. package/out/sdk/loader-node.js +119 -0
  67. package/out/sdk/loader-node.js.map +1 -0
  68. package/out/sdk/loader.d.ts +49 -0
  69. package/out/sdk/loader.js +85 -0
  70. package/out/sdk/loader.js.map +1 -0
  71. package/out/sdk/patterns.d.ts +93 -0
  72. package/out/sdk/patterns.js +123 -0
  73. package/out/sdk/patterns.js.map +1 -0
  74. package/out/sdk/query.d.ts +90 -0
  75. package/out/sdk/query.js +679 -0
  76. package/out/sdk/query.js.map +1 -0
  77. package/out/sdk/resolution.d.ts +52 -0
  78. package/out/sdk/resolution.js +68 -0
  79. package/out/sdk/resolution.js.map +1 -0
  80. package/out/sdk/types.d.ts +280 -0
  81. package/out/sdk/types.js +8 -0
  82. package/out/sdk/types.js.map +1 -0
  83. package/out/services/dependency-analyzer.d.ts +58 -0
  84. package/out/services/dependency-analyzer.js +254 -0
  85. package/out/services/dependency-analyzer.js.map +1 -0
  86. package/out/services/dependency-resolver.d.ts +146 -0
  87. package/out/services/dependency-resolver.js +452 -0
  88. package/out/services/dependency-resolver.js.map +1 -0
  89. package/out/services/git-url-resolver.browser.d.ts +10 -0
  90. package/out/services/git-url-resolver.browser.js +19 -0
  91. package/out/services/git-url-resolver.browser.js.map +1 -0
  92. package/out/services/git-url-resolver.d.ts +158 -0
  93. package/out/services/git-url-resolver.js +416 -0
  94. package/out/services/git-url-resolver.js.map +1 -0
  95. package/out/services/governance-validator.d.ts +44 -0
  96. package/out/services/governance-validator.js +153 -0
  97. package/out/services/governance-validator.js.map +1 -0
  98. package/out/services/import-resolver.d.ts +77 -0
  99. package/out/services/import-resolver.js +240 -0
  100. package/out/services/import-resolver.js.map +1 -0
  101. package/out/services/performance-optimizer.d.ts +60 -0
  102. package/out/services/performance-optimizer.js +140 -0
  103. package/out/services/performance-optimizer.js.map +1 -0
  104. package/out/services/relationship-inference.d.ts +11 -0
  105. package/out/services/relationship-inference.js +98 -0
  106. package/out/services/relationship-inference.js.map +1 -0
  107. package/out/services/semver.d.ts +98 -0
  108. package/out/services/semver.js +195 -0
  109. package/out/services/semver.js.map +1 -0
  110. package/out/services/types.d.ts +340 -0
  111. package/out/services/types.js +46 -0
  112. package/out/services/types.js.map +1 -0
  113. package/out/services/workspace-manager.d.ts +123 -0
  114. package/out/services/workspace-manager.js +489 -0
  115. package/out/services/workspace-manager.js.map +1 -0
  116. package/out/syntaxes/domain-lang.monarch.d.ts +76 -0
  117. package/out/syntaxes/domain-lang.monarch.js +29 -0
  118. package/out/syntaxes/domain-lang.monarch.js.map +1 -0
  119. package/out/utils/import-utils.d.ts +49 -0
  120. package/out/utils/import-utils.js +128 -0
  121. package/out/utils/import-utils.js.map +1 -0
  122. package/out/validation/bounded-context.d.ts +11 -0
  123. package/out/validation/bounded-context.js +79 -0
  124. package/out/validation/bounded-context.js.map +1 -0
  125. package/out/validation/classification.d.ts +3 -0
  126. package/out/validation/classification.js +3 -0
  127. package/out/validation/classification.js.map +1 -0
  128. package/out/validation/constants.d.ts +180 -0
  129. package/out/validation/constants.js +235 -0
  130. package/out/validation/constants.js.map +1 -0
  131. package/out/validation/domain-lang-validator.d.ts +2 -0
  132. package/out/validation/domain-lang-validator.js +27 -0
  133. package/out/validation/domain-lang-validator.js.map +1 -0
  134. package/out/validation/domain.d.ts +11 -0
  135. package/out/validation/domain.js +63 -0
  136. package/out/validation/domain.js.map +1 -0
  137. package/out/validation/import.d.ts +68 -0
  138. package/out/validation/import.js +237 -0
  139. package/out/validation/import.js.map +1 -0
  140. package/out/validation/manifest.d.ts +144 -0
  141. package/out/validation/manifest.js +327 -0
  142. package/out/validation/manifest.js.map +1 -0
  143. package/out/validation/maps.d.ts +21 -0
  144. package/out/validation/maps.js +60 -0
  145. package/out/validation/maps.js.map +1 -0
  146. package/out/validation/metadata.d.ts +7 -0
  147. package/out/validation/metadata.js +16 -0
  148. package/out/validation/metadata.js.map +1 -0
  149. package/out/validation/model.d.ts +12 -0
  150. package/out/validation/model.js +29 -0
  151. package/out/validation/model.js.map +1 -0
  152. package/out/validation/relationships.d.ts +12 -0
  153. package/out/validation/relationships.js +94 -0
  154. package/out/validation/relationships.js.map +1 -0
  155. package/out/validation/shared.d.ts +6 -0
  156. package/out/validation/shared.js +12 -0
  157. package/out/validation/shared.js.map +1 -0
  158. package/package.json +110 -0
  159. package/src/ast-augmentation.ts +5 -0
  160. package/src/domain-lang-module.ts +112 -0
  161. package/src/domain-lang.langium +351 -0
  162. package/src/generated/ast.ts +986 -0
  163. package/src/generated/grammar.ts +2409 -0
  164. package/src/generated/module.ts +25 -0
  165. package/src/index.ts +24 -0
  166. package/src/lsp/domain-lang-code-actions.ts +189 -0
  167. package/src/lsp/domain-lang-completion.ts +514 -0
  168. package/src/lsp/domain-lang-formatter.ts +51 -0
  169. package/src/lsp/domain-lang-naming.ts +56 -0
  170. package/src/lsp/domain-lang-scope.ts +137 -0
  171. package/src/lsp/domain-lang-workspace-manager.ts +104 -0
  172. package/src/lsp/hover/ddd-pattern-explanations.ts +237 -0
  173. package/src/lsp/hover/domain-lang-hover.ts +338 -0
  174. package/src/lsp/hover/domain-lang-keywords.ts +50 -0
  175. package/src/lsp/manifest-diagnostics.ts +290 -0
  176. package/src/main-browser.ts +15 -0
  177. package/src/main.ts +85 -0
  178. package/src/sdk/README.md +297 -0
  179. package/src/sdk/ast-augmentation.ts +157 -0
  180. package/src/sdk/index.ts +126 -0
  181. package/src/sdk/indexes.ts +155 -0
  182. package/src/sdk/loader-node.ts +146 -0
  183. package/src/sdk/loader.ts +99 -0
  184. package/src/sdk/patterns.ts +147 -0
  185. package/src/sdk/query.ts +802 -0
  186. package/src/sdk/resolution.ts +78 -0
  187. package/src/sdk/types.ts +323 -0
  188. package/src/services/dependency-analyzer.ts +321 -0
  189. package/src/services/dependency-resolver.ts +551 -0
  190. package/src/services/git-url-resolver.browser.ts +26 -0
  191. package/src/services/git-url-resolver.ts +517 -0
  192. package/src/services/governance-validator.ts +177 -0
  193. package/src/services/import-resolver.ts +292 -0
  194. package/src/services/performance-optimizer.ts +170 -0
  195. package/src/services/relationship-inference.ts +121 -0
  196. package/src/services/semver.ts +213 -0
  197. package/src/services/types.ts +415 -0
  198. package/src/services/workspace-manager.ts +607 -0
  199. package/src/syntaxes/domain-lang.monarch.ts +29 -0
  200. package/src/utils/import-utils.ts +152 -0
  201. package/src/validation/bounded-context.ts +99 -0
  202. package/src/validation/classification.ts +5 -0
  203. package/src/validation/constants.ts +304 -0
  204. package/src/validation/domain-lang-validator.ts +33 -0
  205. package/src/validation/domain.ts +77 -0
  206. package/src/validation/import.ts +295 -0
  207. package/src/validation/manifest.ts +439 -0
  208. package/src/validation/maps.ts +76 -0
  209. package/src/validation/metadata.ts +18 -0
  210. package/src/validation/model.ts +37 -0
  211. package/src/validation/relationships.ts +154 -0
  212. package/src/validation/shared.ts +14 -0
@@ -0,0 +1,254 @@
1
+ /**
2
+ * Dependency Analysis Service
3
+ *
4
+ * Provides tools for visualizing and analyzing dependency relationships:
5
+ * - Dependency tree visualization
6
+ * - Impact analysis (reverse dependencies)
7
+ * - Circular dependency detection
8
+ * - Version policy enforcement
9
+ */
10
+ import path from 'node:path';
11
+ import fs from 'node:fs/promises';
12
+ import os from 'node:os';
13
+ import YAML from 'yaml';
14
+ import { sortVersionsDescending, isPreRelease } from './semver.js';
15
+ /**
16
+ * Analyzes dependency relationships and provides visualization/analysis tools.
17
+ */
18
+ export class DependencyAnalyzer {
19
+ /**
20
+ * Builds a dependency tree from a lock file.
21
+ *
22
+ * @param lockFile - The lock file to analyze
23
+ * @param workspaceRoot - Workspace root to load dependency metadata
24
+ * @returns Root nodes of the dependency tree
25
+ */
26
+ async buildDependencyTree(lockFile, workspaceRoot) {
27
+ const manifestPath = path.join(workspaceRoot, 'model.yaml');
28
+ // Load root manifest to get direct dependencies
29
+ const rootDeps = {};
30
+ try {
31
+ const content = await fs.readFile(manifestPath, 'utf-8');
32
+ const manifest = YAML.parse(content);
33
+ if (manifest.dependencies) {
34
+ for (const [, dep] of Object.entries(manifest.dependencies)) {
35
+ rootDeps[dep.source] = dep.version;
36
+ }
37
+ }
38
+ }
39
+ catch {
40
+ // No manifest or parse error
41
+ }
42
+ // Build tree for each direct dependency
43
+ const rootNodes = [];
44
+ const visited = new Set();
45
+ for (const packageKey of Object.keys(rootDeps)) {
46
+ const node = await this.buildTreeNode(packageKey, lockFile, workspaceRoot, 0, visited);
47
+ if (node) {
48
+ rootNodes.push(node);
49
+ }
50
+ }
51
+ return rootNodes;
52
+ }
53
+ /**
54
+ * Recursively builds a dependency tree node.
55
+ */
56
+ async buildTreeNode(packageKey, lockFile, workspaceRoot, depth, visited) {
57
+ const locked = lockFile.dependencies[packageKey];
58
+ if (!locked) {
59
+ return null;
60
+ }
61
+ // Prevent infinite recursion
62
+ if (visited.has(packageKey)) {
63
+ return {
64
+ packageKey,
65
+ ref: locked.ref,
66
+ commit: locked.commit,
67
+ dependencies: [], // Don't recurse into already visited
68
+ depth,
69
+ };
70
+ }
71
+ visited.add(packageKey);
72
+ // Load package dependencies from cache
73
+ const cacheDir = this.getCacheDir(packageKey, locked.commit);
74
+ const packageDeps = await this.loadPackageDependencies(cacheDir);
75
+ // Build child nodes
76
+ const children = [];
77
+ for (const depKey of Object.keys(packageDeps)) {
78
+ const childNode = await this.buildTreeNode(depKey, lockFile, workspaceRoot, depth + 1, new Set(visited));
79
+ if (childNode) {
80
+ children.push(childNode);
81
+ }
82
+ }
83
+ return {
84
+ packageKey,
85
+ ref: locked.ref,
86
+ commit: locked.commit,
87
+ dependencies: children,
88
+ depth,
89
+ };
90
+ }
91
+ /**
92
+ * Finds all packages that depend on a given package.
93
+ *
94
+ * @param targetPackage - Package to analyze
95
+ * @param lockFile - Lock file with all dependencies
96
+ * @param workspaceRoot - Workspace root
97
+ * @returns List of reverse dependencies
98
+ */
99
+ async findReverseDependencies(targetPackage, lockFile, workspaceRoot) {
100
+ const reverseDeps = [];
101
+ const manifestPath = path.join(workspaceRoot, 'model.yaml');
102
+ // Check if target is a direct dependency of root
103
+ try {
104
+ const content = await fs.readFile(manifestPath, 'utf-8');
105
+ const manifest = YAML.parse(content);
106
+ if (manifest.dependencies) {
107
+ for (const [, dep] of Object.entries(manifest.dependencies)) {
108
+ if (dep.source === targetPackage) {
109
+ reverseDeps.push({
110
+ dependentPackage: 'root',
111
+ ref: 'workspace',
112
+ type: 'direct',
113
+ });
114
+ }
115
+ }
116
+ }
117
+ }
118
+ catch {
119
+ // Ignore
120
+ }
121
+ // Check all other packages in lock file
122
+ for (const [packageKey, locked] of Object.entries(lockFile.dependencies)) {
123
+ if (packageKey === targetPackage) {
124
+ continue;
125
+ }
126
+ const cacheDir = this.getCacheDir(packageKey, locked.commit);
127
+ const packageDeps = await this.loadPackageDependencies(cacheDir);
128
+ if (packageDeps[targetPackage]) {
129
+ reverseDeps.push({
130
+ dependentPackage: packageKey,
131
+ ref: locked.ref,
132
+ type: 'direct',
133
+ });
134
+ }
135
+ }
136
+ return reverseDeps;
137
+ }
138
+ /**
139
+ * Formats a dependency tree as a readable string.
140
+ */
141
+ formatDependencyTree(nodes, options = {}) {
142
+ const lines = [];
143
+ const formatNode = (node, prefix, isLast) => {
144
+ const branch = isLast ? '└── ' : '├── ';
145
+ const refStr = options.showCommits
146
+ ? `${node.ref} (${node.commit.substring(0, 7)})`
147
+ : node.ref;
148
+ lines.push(`${prefix}${branch}${node.packageKey}@${refStr}`);
149
+ const childPrefix = prefix + (isLast ? ' ' : '│ ');
150
+ node.dependencies.forEach((child, index) => {
151
+ const isLastChild = index === node.dependencies.length - 1;
152
+ formatNode(child, childPrefix, isLastChild);
153
+ });
154
+ };
155
+ nodes.forEach((node, index) => {
156
+ formatNode(node, '', index === nodes.length - 1);
157
+ });
158
+ return lines.join('\n');
159
+ }
160
+ /**
161
+ * Detects circular dependencies in a dependency graph.
162
+ */
163
+ async detectCircularDependencies(lockFile) {
164
+ const cycles = [];
165
+ const visiting = new Set();
166
+ const completed = new Set();
167
+ const dfs = async (packageKey, path) => {
168
+ if (visiting.has(packageKey)) {
169
+ const cycleStart = path.indexOf(packageKey);
170
+ const cycle = cycleStart >= 0
171
+ ? [...path.slice(cycleStart), packageKey]
172
+ : [...path, packageKey];
173
+ cycles.push(cycle);
174
+ return;
175
+ }
176
+ if (completed.has(packageKey)) {
177
+ return;
178
+ }
179
+ visiting.add(packageKey);
180
+ const locked = lockFile.dependencies[packageKey];
181
+ if (locked) {
182
+ const cacheDir = this.getCacheDir(packageKey, locked.commit);
183
+ const deps = await this.loadPackageDependencies(cacheDir);
184
+ for (const depKey of Object.keys(deps)) {
185
+ await dfs(depKey, [...path, packageKey]);
186
+ }
187
+ }
188
+ visiting.delete(packageKey);
189
+ completed.add(packageKey);
190
+ };
191
+ for (const packageKey of Object.keys(lockFile.dependencies)) {
192
+ await dfs(packageKey, []);
193
+ }
194
+ return cycles;
195
+ }
196
+ /**
197
+ * Resolves ref policies (latest, stable) to concrete refs.
198
+ */
199
+ async resolveVersionPolicy(_packageKey, policy, availableRefs) {
200
+ if (policy === 'latest') {
201
+ // Return the most recent ref
202
+ const sorted = sortVersionsDescending(availableRefs);
203
+ return {
204
+ policy: 'latest',
205
+ ref: sorted[0] || 'main',
206
+ availableRefs: sorted,
207
+ };
208
+ }
209
+ if (policy === 'stable') {
210
+ // Return the most recent stable ref (exclude pre-release)
211
+ const stable = availableRefs.filter(v => !isPreRelease(v));
212
+ const sorted = sortVersionsDescending(stable);
213
+ return {
214
+ policy: 'stable',
215
+ ref: sorted[0] || 'main',
216
+ availableRefs: sorted,
217
+ };
218
+ }
219
+ // Pinned ref
220
+ return {
221
+ policy: 'pinned',
222
+ ref: policy,
223
+ };
224
+ }
225
+ /**
226
+ * Gets the cache directory for a package.
227
+ */
228
+ getCacheDir(packageKey, commit) {
229
+ const [owner, repo] = packageKey.split('/');
230
+ return path.join(os.homedir(), '.dlang', 'cache', 'github', // Assume GitHub for now
231
+ owner, repo, commit);
232
+ }
233
+ /**
234
+ * Loads dependencies from a cached package.
235
+ */
236
+ async loadPackageDependencies(cacheDir) {
237
+ const manifestPath = path.join(cacheDir, 'model.yaml');
238
+ try {
239
+ const content = await fs.readFile(manifestPath, 'utf-8');
240
+ const manifest = YAML.parse(content);
241
+ const deps = {};
242
+ if (manifest.dependencies) {
243
+ for (const [, dep] of Object.entries(manifest.dependencies)) {
244
+ deps[dep.source] = dep.version;
245
+ }
246
+ }
247
+ return deps;
248
+ }
249
+ catch {
250
+ return {};
251
+ }
252
+ }
253
+ }
254
+ //# sourceMappingURL=dependency-analyzer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"d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,MAAM,CAAC;YACL,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC;CACJ"}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Dependency Resolution Service
3
+ *
4
+ * Discovers and resolves transitive dependencies for DomainLang packages.
5
+ * Generates lock files for reproducible builds.
6
+ *
7
+ * Algorithm:
8
+ * 1. Parse root model.yaml
9
+ * 2. Download all direct dependencies
10
+ * 3. Parse each dependency's model.yaml
11
+ * 4. Recursively discover transitive dependencies
12
+ * 5. Resolve version constraints using "Latest Wins" strategy
13
+ * 6. Generate lock file with pinned commit hashes
14
+ *
15
+ * Resolution Strategy ("Latest Wins"):
16
+ * - SemVer tags (same major): Pick highest compatible version
17
+ * - Same branch: No conflict, resolve once
18
+ * - Commit pins: Error (explicit pins are intentional)
19
+ * - Major version mismatch: Error
20
+ * - Tag vs Branch: Error (incompatible intent)
21
+ */
22
+ import { GitUrlResolver } from './git-url-resolver.js';
23
+ import type { LockFile } from './types.js';
24
+ export declare class DependencyResolver {
25
+ private gitResolver;
26
+ private workspaceRoot;
27
+ constructor(workspaceRoot: string, gitResolver?: GitUrlResolver);
28
+ /**
29
+ * Resolves all dependencies for a workspace.
30
+ *
31
+ * Process:
32
+ * 1. Load root model.yaml
33
+ * 2. Build dependency graph (discover transitive deps)
34
+ * 3. Resolve version constraints
35
+ * 4. Generate lock file
36
+ * 5. Download all dependencies to cache
37
+ *
38
+ * @returns Generated lock file
39
+ */
40
+ resolveDependencies(): Promise<LockFile>;
41
+ /**
42
+ * Applies ref overrides from model.yaml to resolve conflicts explicitly.
43
+ *
44
+ * Overrides take precedence over all other constraints.
45
+ *
46
+ * @example
47
+ * ```yaml
48
+ * overrides:
49
+ * domainlang/core: v2.0.0
50
+ * ```
51
+ */
52
+ private applyOverrides;
53
+ /** Override messages for CLI output */
54
+ private overrideMessages;
55
+ /**
56
+ * Returns any override messages from the last dependency resolution.
57
+ */
58
+ getOverrideMessages(): string[];
59
+ /**
60
+ * Builds the complete dependency graph by recursively discovering transitive dependencies.
61
+ */
62
+ private buildDependencyGraph;
63
+ /**
64
+ * Resolves ref constraints to specific commits.
65
+ *
66
+ * Simple algorithm: Use the ref specified in the constraint.
67
+ * Detects refType (tag, branch, or commit) based on format.
68
+ */
69
+ private resolveVersions;
70
+ /**
71
+ * Extracts a ref from a constraint string.
72
+ *
73
+ * Examples:
74
+ * - "^1.0.0" → "1.0.0" (treated as tag)
75
+ * - "~2.3.0" → "2.3.0" (treated as tag)
76
+ * - "1.5.0" → "1.5.0" (treated as tag)
77
+ * - "main" → "main" (treated as branch)
78
+ * - "abc123def" → "abc123def" (treated as commit)
79
+ * - "owner/repo@1.0.0" → "1.0.0"
80
+ */
81
+ private extractRefFromConstraint;
82
+ /**
83
+ * Resolves a version (tag/branch) to a commit hash using git ls-remote.
84
+ */
85
+ private resolveCommitHash;
86
+ /**
87
+ * Generates a lock file from the resolved dependency graph.
88
+ */
89
+ private generateLockFile;
90
+ /**
91
+ * Loads and parses a package's model.yaml file.
92
+ */
93
+ private loadPackageConfig;
94
+ /**
95
+ * Parses model.yaml content.
96
+ *
97
+ * Expected structure:
98
+ * model:
99
+ * name: package-name
100
+ * version: 1.0.0
101
+ * entry: index.dlang
102
+ *
103
+ * dependencies:
104
+ * package-name:
105
+ * source: owner/repo
106
+ * ref: v1.0.0
107
+ */
108
+ private parseYaml;
109
+ /**
110
+ * Detects ref conflicts and applies "Latest Wins" resolution strategy.
111
+ *
112
+ * Resolution Rules:
113
+ * - SemVer tags (same major): Pick highest version automatically
114
+ * - Same branch refs: No conflict, use single resolution
115
+ * - Commit SHA conflicts: Error (explicit pins are intentional)
116
+ * - Major version mismatch: Error (breaking change)
117
+ * - Tag vs Branch: Error (incompatible intent)
118
+ *
119
+ * Modifies graph nodes in-place to set the resolved constraint.
120
+ * Throws an error only for unresolvable conflicts.
121
+ */
122
+ private detectVersionConflicts;
123
+ /**
124
+ * Throws a formatted conflict error with actionable hints.
125
+ */
126
+ private throwConflictError;
127
+ /** Resolution messages from "Latest Wins" auto-resolution */
128
+ private resolutionMessages;
129
+ /**
130
+ * Returns any resolution messages from the last dependency resolution.
131
+ * Useful for CLI output to inform users about auto-resolved conflicts.
132
+ */
133
+ getResolutionMessages(): string[];
134
+ /**
135
+ * Detects package-level cycles in the dependency graph and throws a clear error.
136
+ */
137
+ private detectPackageCycles;
138
+ /**
139
+ * Loads an existing lock file from disk.
140
+ */
141
+ static loadLockFile(workspaceRoot: string): Promise<LockFile | undefined>;
142
+ /**
143
+ * Parses a lock file from JSON format.
144
+ */
145
+ static parseLockFile(content: string): LockFile;
146
+ }