@akanjs/devkit 1.0.20 → 2.1.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/aiEditor.ts +304 -0
  2. package/akanApp/akanApp.host.ts +393 -0
  3. package/akanApp/index.ts +1 -0
  4. package/akanConfig/akanConfig.test.ts +236 -0
  5. package/akanConfig/akanConfig.ts +384 -0
  6. package/akanConfig/index.ts +2 -0
  7. package/akanConfig/types.ts +23 -0
  8. package/applicationBuildReporter.ts +69 -0
  9. package/applicationBuildRunner.ts +302 -0
  10. package/applicationReleasePackager.ts +206 -0
  11. package/artifact/implicitRootLayout.ts +155 -0
  12. package/artifact/index.ts +1 -0
  13. package/artifact/routeSeedIndex.test.ts +98 -0
  14. package/artifact/routeSeedIndex.ts +130 -0
  15. package/auth.ts +41 -0
  16. package/builder.ts +164 -0
  17. package/capacitor.base.config.ts +88 -0
  18. package/capacitorApp.ts +440 -0
  19. package/commandDecorators/argMeta.ts +102 -0
  20. package/commandDecorators/command.ts +343 -0
  21. package/commandDecorators/commandBuilder.ts +224 -0
  22. package/commandDecorators/commandDecorators.test.ts +212 -0
  23. package/commandDecorators/commandMeta.ts +7 -0
  24. package/commandDecorators/dependencyBuilder.ts +100 -0
  25. package/{esm/src/commandDecorators/helpFormatter.js → commandDecorators/helpFormatter.ts} +100 -47
  26. package/{esm/src/commandDecorators/index.js → commandDecorators/index.ts} +4 -2
  27. package/commandDecorators/targetMeta.ts +31 -0
  28. package/commandDecorators/types.ts +10 -0
  29. package/constants.ts +25 -0
  30. package/createTunnel.ts +36 -0
  31. package/dependencyScanner.ts +357 -0
  32. package/devkitUtils.test.ts +259 -0
  33. package/executors.test.ts +315 -0
  34. package/executors.ts +1390 -0
  35. package/{esm/src/extractDeps.js → extractDeps.ts} +26 -20
  36. package/{esm/src/fileEditor.js → fileEditor.ts} +51 -32
  37. package/fileSys.ts +39 -0
  38. package/frontendBuild/allRoutesBuilder.ts +103 -0
  39. package/frontendBuild/buildRouteClient.test.ts +190 -0
  40. package/frontendBuild/clientBuildTypes.ts +114 -0
  41. package/frontendBuild/clientEntriesBundler.ts +303 -0
  42. package/frontendBuild/clientEntryDiscovery.ts +199 -0
  43. package/frontendBuild/csrArtifactBuilder.ts +237 -0
  44. package/frontendBuild/cssCompiler.ts +286 -0
  45. package/frontendBuild/cssImportResolver.ts +116 -0
  46. package/frontendBuild/fontOptimizer.ts +427 -0
  47. package/frontendBuild/frontendBuild.test.ts +204 -0
  48. package/frontendBuild/hmrChangeClassifier.ts +28 -0
  49. package/frontendBuild/hmrWatcher.ts +102 -0
  50. package/frontendBuild/index.ts +18 -0
  51. package/frontendBuild/pagesBundleBuilder.ts +137 -0
  52. package/frontendBuild/pagesEntrySourceGenerator.ts +37 -0
  53. package/frontendBuild/precompressArtifacts.ts +59 -0
  54. package/frontendBuild/routeClientBuilder.ts +290 -0
  55. package/frontendBuild/routesManifestArtifactSerializer.ts +62 -0
  56. package/frontendBuild/ssrBaseArtifactBuilder.ts +139 -0
  57. package/frontendBuild/vendorSpecifiers.ts +16 -0
  58. package/frontendBuild/watchRootResolver.ts +28 -0
  59. package/getCredentials.ts +19 -0
  60. package/getDirname.ts +3 -0
  61. package/getModelFileData.ts +59 -0
  62. package/getRelatedCnsts.ts +313 -0
  63. package/guideline.ts +19 -0
  64. package/incrementalBuilder/incrementalBuilder.host.test.ts +51 -0
  65. package/incrementalBuilder/incrementalBuilder.host.ts +152 -0
  66. package/incrementalBuilder/incrementalBuilder.proc.ts +331 -0
  67. package/incrementalBuilder/index.ts +1 -0
  68. package/{esm/src/index.js → index.ts} +28 -15
  69. package/lint/no-deep-internal-import.grit +25 -0
  70. package/lint/no-import-client-functions.grit +32 -0
  71. package/lint/no-import-external-library.grit +21 -0
  72. package/lint/no-js-private-class-method.grit +42 -0
  73. package/lint/no-use-client-in-server.grit +7 -0
  74. package/lint/non-scalar-props-restricted.grit +13 -0
  75. package/linter.ts +271 -0
  76. package/mobile/index.ts +1 -0
  77. package/mobile/mobileTarget.test.ts +53 -0
  78. package/mobile/mobileTarget.ts +88 -0
  79. package/package.json +48 -31
  80. package/prompter.ts +72 -0
  81. package/scanInfo.ts +606 -0
  82. package/selectModel.ts +11 -0
  83. package/{esm/src/spinner.js → spinner.ts} +22 -28
  84. package/{esm/src/capacitorApp.js → src/capacitorApp.ts} +82 -81
  85. package/sshTunnel.ts +152 -0
  86. package/{esm/src/streamAi.js → streamAi.ts} +18 -12
  87. package/transforms/barrelAnalyzer.ts +278 -0
  88. package/transforms/barrelImportsPlugin.ts +504 -0
  89. package/transforms/externalizeFrameworkPlugin.ts +185 -0
  90. package/transforms/index.ts +5 -0
  91. package/transforms/rscUseClientTransform.ts +59 -0
  92. package/transforms/transforms.test.ts +208 -0
  93. package/transforms/useClientBundlePlugin.ts +47 -0
  94. package/tsconfig.json +37 -0
  95. package/typeChecker.ts +264 -0
  96. package/types.ts +44 -0
  97. package/ui/MultiScrollList.tsx +242 -0
  98. package/ui/ScrollList.tsx +107 -0
  99. package/ui/index.ts +2 -0
  100. package/{esm/src/uploadRelease.js → uploadRelease.ts} +50 -34
  101. package/{esm/src/useStdoutDimensions.js → useStdoutDimensions.ts} +5 -5
  102. package/README.md +0 -7
  103. package/cjs/index.js +0 -21
  104. package/cjs/src/aiEditor.js +0 -311
  105. package/cjs/src/auth.js +0 -72
  106. package/cjs/src/builder.js +0 -114
  107. package/cjs/src/capacitorApp.js +0 -313
  108. package/cjs/src/commandDecorators/argMeta.js +0 -88
  109. package/cjs/src/commandDecorators/command.js +0 -324
  110. package/cjs/src/commandDecorators/commandMeta.js +0 -30
  111. package/cjs/src/commandDecorators/helpFormatter.js +0 -211
  112. package/cjs/src/commandDecorators/index.js +0 -31
  113. package/cjs/src/commandDecorators/targetMeta.js +0 -57
  114. package/cjs/src/commandDecorators/types.js +0 -15
  115. package/cjs/src/constants.js +0 -46
  116. package/cjs/src/createTunnel.js +0 -49
  117. package/cjs/src/dependencyScanner.js +0 -220
  118. package/cjs/src/executors.js +0 -964
  119. package/cjs/src/extractDeps.js +0 -103
  120. package/cjs/src/fileEditor.js +0 -120
  121. package/cjs/src/getCredentials.js +0 -44
  122. package/cjs/src/getDirname.js +0 -38
  123. package/cjs/src/getModelFileData.js +0 -66
  124. package/cjs/src/getRelatedCnsts.js +0 -260
  125. package/cjs/src/guideline.js +0 -15
  126. package/cjs/src/index.js +0 -65
  127. package/cjs/src/linter.js +0 -238
  128. package/cjs/src/prompter.js +0 -85
  129. package/cjs/src/scanInfo.js +0 -491
  130. package/cjs/src/selectModel.js +0 -46
  131. package/cjs/src/spinner.js +0 -93
  132. package/cjs/src/streamAi.js +0 -62
  133. package/cjs/src/typeChecker.js +0 -207
  134. package/cjs/src/types.js +0 -15
  135. package/cjs/src/uploadRelease.js +0 -112
  136. package/cjs/src/useStdoutDimensions.js +0 -43
  137. package/esm/index.js +0 -1
  138. package/esm/src/aiEditor.js +0 -282
  139. package/esm/src/auth.js +0 -42
  140. package/esm/src/builder.js +0 -81
  141. package/esm/src/commandDecorators/argMeta.js +0 -54
  142. package/esm/src/commandDecorators/command.js +0 -290
  143. package/esm/src/commandDecorators/commandMeta.js +0 -7
  144. package/esm/src/commandDecorators/targetMeta.js +0 -33
  145. package/esm/src/commandDecorators/types.js +0 -0
  146. package/esm/src/constants.js +0 -17
  147. package/esm/src/createTunnel.js +0 -26
  148. package/esm/src/dependencyScanner.js +0 -187
  149. package/esm/src/executors.js +0 -928
  150. package/esm/src/getCredentials.js +0 -11
  151. package/esm/src/getDirname.js +0 -5
  152. package/esm/src/getModelFileData.js +0 -33
  153. package/esm/src/getRelatedCnsts.js +0 -221
  154. package/esm/src/guideline.js +0 -0
  155. package/esm/src/linter.js +0 -205
  156. package/esm/src/prompter.js +0 -51
  157. package/esm/src/scanInfo.js +0 -455
  158. package/esm/src/selectModel.js +0 -13
  159. package/esm/src/typeChecker.js +0 -174
  160. package/esm/src/types.js +0 -0
  161. package/index.d.ts +0 -1
  162. package/src/aiEditor.d.ts +0 -50
  163. package/src/auth.d.ts +0 -9
  164. package/src/builder.d.ts +0 -18
  165. package/src/capacitorApp.d.ts +0 -39
  166. package/src/commandDecorators/argMeta.d.ts +0 -67
  167. package/src/commandDecorators/command.d.ts +0 -2
  168. package/src/commandDecorators/commandMeta.d.ts +0 -2
  169. package/src/commandDecorators/helpFormatter.d.ts +0 -3
  170. package/src/commandDecorators/index.d.ts +0 -6
  171. package/src/commandDecorators/targetMeta.d.ts +0 -19
  172. package/src/commandDecorators/types.d.ts +0 -1
  173. package/src/constants.d.ts +0 -26
  174. package/src/createTunnel.d.ts +0 -8
  175. package/src/dependencyScanner.d.ts +0 -23
  176. package/src/executors.d.ts +0 -296
  177. package/src/extractDeps.d.ts +0 -7
  178. package/src/fileEditor.d.ts +0 -16
  179. package/src/getCredentials.d.ts +0 -12
  180. package/src/getDirname.d.ts +0 -1
  181. package/src/getModelFileData.d.ts +0 -16
  182. package/src/getRelatedCnsts.d.ts +0 -53
  183. package/src/guideline.d.ts +0 -19
  184. package/src/index.d.ts +0 -23
  185. package/src/linter.d.ts +0 -109
  186. package/src/prompter.d.ts +0 -14
  187. package/src/scanInfo.d.ts +0 -82
  188. package/src/selectModel.d.ts +0 -1
  189. package/src/spinner.d.ts +0 -20
  190. package/src/streamAi.d.ts +0 -6
  191. package/src/typeChecker.d.ts +0 -52
  192. package/src/types.d.ts +0 -31
  193. package/src/uploadRelease.d.ts +0 -10
  194. package/src/useStdoutDimensions.d.ts +0 -1
@@ -1,491 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var scanInfo_exports = {};
29
- __export(scanInfo_exports, {
30
- AppInfo: () => AppInfo,
31
- LibInfo: () => LibInfo,
32
- PkgInfo: () => PkgInfo,
33
- WorkspaceInfo: () => WorkspaceInfo
34
- });
35
- module.exports = __toCommonJS(scanInfo_exports);
36
- var import_path = __toESM(require("path"));
37
- var import_dependencyScanner = require("./dependencyScanner");
38
- var import_executors = require("./executors");
39
- const scalarFileTypes = ["constant", "dictionary", "document", "template", "unit", "util", "view", "zone"];
40
- const serviceFileTypes = [
41
- "dictionary",
42
- "service",
43
- "signal",
44
- "store",
45
- "template",
46
- "unit",
47
- "util",
48
- "view",
49
- "zone"
50
- ];
51
- const databaseFileTypes = [
52
- "constant",
53
- "dictionary",
54
- "document",
55
- "service",
56
- "signal",
57
- "store",
58
- "template",
59
- "unit",
60
- "util",
61
- "view",
62
- "zone"
63
- ];
64
- class ScanInfo {
65
- scanResult;
66
- name;
67
- scalar = /* @__PURE__ */ new Map();
68
- service = /* @__PURE__ */ new Map();
69
- database = /* @__PURE__ */ new Map();
70
- file = Object.fromEntries(
71
- databaseFileTypes.map((type) => [
72
- type,
73
- { all: /* @__PURE__ */ new Set(), databases: /* @__PURE__ */ new Set(), services: /* @__PURE__ */ new Set(), scalars: /* @__PURE__ */ new Set() }
74
- ])
75
- );
76
- static async getScanResult(exec) {
77
- const akanConfig = await exec.getConfig();
78
- const tsconfig = exec.getTsConfig();
79
- const rootPackageJson = exec.workspace.getPackageJson();
80
- const gitignorePatterns = exec.workspace.getGitignorePatterns();
81
- const scanner = new import_dependencyScanner.TypeScriptDependencyScanner(exec.cwdPath, {
82
- workspaceRoot: exec.workspace.cwdPath,
83
- tsconfig,
84
- rootPackageJson,
85
- gitignorePatterns
86
- });
87
- const { pkgDeps, libDeps, npmDeps } = await scanner.getMonorepoDependencies(exec.name);
88
- const files = {
89
- constant: { databases: [], scalars: [] },
90
- dictionary: { databases: [], services: [], scalars: [] },
91
- document: { databases: [], scalars: [] },
92
- service: { databases: [], services: [] },
93
- signal: { databases: [], services: [] },
94
- store: { databases: [], services: [] },
95
- template: { databases: [], services: [], scalars: [] },
96
- unit: { databases: [], services: [], scalars: [] },
97
- util: { databases: [], services: [], scalars: [] },
98
- view: { databases: [], services: [], scalars: [] },
99
- zone: { databases: [], services: [], scalars: [] }
100
- };
101
- const [{ dirs: dirnames }, scalarDirs] = await Promise.all([
102
- exec.getFilesAndDirs("lib"),
103
- exec.readdir("lib/__scalar")
104
- ]);
105
- const databaseDirs = [];
106
- const serviceDirs = [];
107
- dirnames.forEach((name) => {
108
- if (name.startsWith("_")) {
109
- if (name.startsWith("__"))
110
- return;
111
- else
112
- serviceDirs.push(name);
113
- } else
114
- databaseDirs.push(name);
115
- });
116
- await Promise.all([
117
- ...databaseDirs.map(async (name) => {
118
- const filenames = await exec.readdir(import_path.default.join("lib", name));
119
- filenames.forEach((filename) => {
120
- if (filename.endsWith(".constant.ts"))
121
- files.constant.databases.push(name);
122
- else if (filename.endsWith(".dictionary.ts"))
123
- files.dictionary.databases.push(name);
124
- else if (filename.endsWith(".document.ts"))
125
- files.document.databases.push(name);
126
- else if (filename.endsWith(".service.ts"))
127
- files.service.databases.push(name);
128
- else if (filename.endsWith(".signal.ts"))
129
- files.signal.databases.push(name);
130
- else if (filename.endsWith(".store.ts"))
131
- files.store.databases.push(name);
132
- else if (filename.endsWith(".Template.tsx"))
133
- files.template.databases.push(name);
134
- else if (filename.endsWith(".Unit.tsx"))
135
- files.unit.databases.push(name);
136
- else if (filename.endsWith(".Util.tsx"))
137
- files.util.databases.push(name);
138
- else if (filename.endsWith(".View.tsx"))
139
- files.view.databases.push(name);
140
- else if (filename.endsWith(".Zone.tsx"))
141
- files.zone.databases.push(name);
142
- });
143
- }),
144
- ...serviceDirs.map(async (dirname) => {
145
- const name = dirname.slice(1);
146
- const filenames = await exec.readdir(import_path.default.join("lib", dirname));
147
- filenames.forEach((filename) => {
148
- if (filename.endsWith(".dictionary.ts"))
149
- files.dictionary.services.push(name);
150
- else if (filename.endsWith(".service.ts"))
151
- files.service.services.push(name);
152
- else if (filename.endsWith(".signal.ts"))
153
- files.signal.services.push(name);
154
- else if (filename.endsWith(".store.ts"))
155
- files.store.services.push(name);
156
- else if (filename.endsWith(".Template.tsx"))
157
- files.template.services.push(name);
158
- else if (filename.endsWith(".Unit.tsx"))
159
- files.unit.services.push(name);
160
- else if (filename.endsWith(".Util.tsx"))
161
- files.util.services.push(name);
162
- else if (filename.endsWith(".View.tsx"))
163
- files.view.services.push(name);
164
- else if (filename.endsWith(".Zone.tsx"))
165
- files.zone.services.push(name);
166
- });
167
- }),
168
- ...scalarDirs.map(async (name) => {
169
- const filenames = await exec.readdir(import_path.default.join("lib/__scalar", name));
170
- filenames.forEach((filename) => {
171
- if (filename.endsWith(".constant.ts"))
172
- files.constant.scalars.push(name);
173
- else if (filename.endsWith(".dictionary.ts"))
174
- files.dictionary.scalars.push(name);
175
- else if (filename.endsWith(".document.ts"))
176
- files.document.scalars.push(name);
177
- else if (filename.endsWith(".Template.tsx"))
178
- files.template.scalars.push(name);
179
- else if (filename.endsWith(".Unit.tsx"))
180
- files.unit.scalars.push(name);
181
- else if (filename.endsWith(".Util.tsx"))
182
- files.util.scalars.push(name);
183
- else if (filename.endsWith(".View.tsx"))
184
- files.view.scalars.push(name);
185
- else if (filename.endsWith(".Zone.tsx"))
186
- files.zone.scalars.push(name);
187
- });
188
- })
189
- ]);
190
- const scanResult = {
191
- name: exec.name,
192
- type: exec.type,
193
- repoName: exec.workspace.repoName,
194
- serveDomain: exec.workspace.getBaseDevEnv().serveDomain,
195
- akanConfig,
196
- files,
197
- libDeps,
198
- pkgDeps,
199
- dependencies: npmDeps.filter((dep) => !dep.startsWith("@akanjs"))
200
- };
201
- return scanResult;
202
- }
203
- constructor(scanResult) {
204
- this.name = scanResult.name;
205
- this.scanResult = scanResult;
206
- Object.entries(scanResult.files).forEach(([_key, value]) => {
207
- const key = _key;
208
- const { databases, services, scalars } = value;
209
- databases.forEach((modelName) => {
210
- const model = this.database.get(modelName) ?? /* @__PURE__ */ new Set();
211
- model.add(key);
212
- this.database.set(modelName, model);
213
- this.file[key].all.add(modelName);
214
- this.file[key].databases.add(modelName);
215
- });
216
- services?.forEach((serviceName) => {
217
- const service = this.service.get(serviceName) ?? /* @__PURE__ */ new Set();
218
- service.add(key);
219
- this.service.set(serviceName, service);
220
- this.file[key].all.add(serviceName);
221
- this.file[key].services.add(serviceName);
222
- });
223
- scalars?.forEach((scalarName) => {
224
- const scalar = this.scalar.get(scalarName) ?? /* @__PURE__ */ new Set();
225
- scalar.add(key);
226
- this.scalar.set(scalarName, scalar);
227
- this.file[key].all.add(scalarName);
228
- this.file[key].scalars.add(scalarName);
229
- });
230
- });
231
- }
232
- getScanResult() {
233
- return this.scanResult;
234
- }
235
- getDatabaseModules() {
236
- return [...this.database.keys()];
237
- }
238
- getServiceModules() {
239
- return [...this.service.keys()];
240
- }
241
- getScalarModules() {
242
- return [...this.scalar.keys()];
243
- }
244
- }
245
- class AppInfo extends ScanInfo {
246
- type = "app";
247
- exec;
248
- akanConfig;
249
- libDeps;
250
- static appInfos = /* @__PURE__ */ new Map();
251
- static async fromExecutor(exec, options = {}) {
252
- const existingAppInfo = this.appInfos.get(exec.name);
253
- if (existingAppInfo && !options.refresh)
254
- return existingAppInfo;
255
- const scanResult = await super.getScanResult(exec);
256
- await Promise.all(
257
- scanResult.libDeps.map(async (libName) => {
258
- LibInfo.loadedLibs.add(libName);
259
- const libExecutor = import_executors.LibExecutor.from(exec, libName);
260
- LibInfo.libInfos.set(libName, await LibInfo.fromExecutor(libExecutor));
261
- })
262
- );
263
- const libDeps = await this.#getAllLibDeps(exec, scanResult.libDeps);
264
- const appInfo = new AppInfo(exec, scanResult, libDeps);
265
- this.appInfos.set(exec.name, appInfo);
266
- return appInfo;
267
- }
268
- constructor(exec, scanResult, libDeps) {
269
- super(scanResult);
270
- this.exec = exec;
271
- this.akanConfig = scanResult.akanConfig;
272
- this.libDeps = libDeps;
273
- }
274
- getScanResult() {
275
- return this.scanResult;
276
- }
277
- static async #getAllLibDeps(exec, libDeps, libSet = /* @__PURE__ */ new Set()) {
278
- await Promise.all(
279
- libDeps.map(async (libName) => {
280
- if (libSet.has(libName))
281
- return;
282
- libSet.add(libName);
283
- const libExecutor = import_executors.LibExecutor.from(exec, libName);
284
- const libInfo = await LibInfo.fromExecutor(libExecutor);
285
- const libScanResult = libInfo.getScanResult();
286
- if (libScanResult.libDeps.length > 0)
287
- await this.#getAllLibDeps(exec, libScanResult.libDeps, libSet);
288
- })
289
- );
290
- return [...libSet];
291
- }
292
- #sortedLibs = null;
293
- #getSortedLibs() {
294
- if (this.#sortedLibs)
295
- return this.#sortedLibs;
296
- const libIndices = LibInfo.getSortedLibIndices();
297
- this.#sortedLibs = this.libDeps.sort((libNameA, libNameB) => {
298
- const indexA = libIndices.get(libNameA);
299
- const indexB = libIndices.get(libNameB);
300
- if (indexA === void 0 || indexB === void 0)
301
- throw new Error(`LibInfo not found: ${libNameA} or ${libNameB}`);
302
- return indexA - indexB;
303
- });
304
- return this.#sortedLibs;
305
- }
306
- getLibs() {
307
- return this.#getSortedLibs();
308
- }
309
- getLibInfos() {
310
- return new Map(
311
- this.#getSortedLibs().map((libName) => {
312
- const libInfo = LibInfo.libInfos.get(libName);
313
- if (!libInfo)
314
- throw new Error(`LibInfo not found: ${libName}`);
315
- return [libName, libInfo];
316
- })
317
- );
318
- }
319
- }
320
- class LibInfo extends ScanInfo {
321
- type = "lib";
322
- exec;
323
- akanConfig;
324
- static loadedLibs = /* @__PURE__ */ new Set();
325
- static libInfos = /* @__PURE__ */ new Map();
326
- static #sortedLibIndices = null;
327
- static getSortedLibIndices() {
328
- if (this.#sortedLibIndices)
329
- return this.#sortedLibIndices;
330
- this.#sortedLibIndices = new Map(
331
- [...this.libInfos.entries()].sort(([_, libInfoA], [__, libInfoB]) => libInfoA.getScanResult().libDeps.includes(libInfoB.name) ? 1 : -1).map(([libName], index) => [libName, index])
332
- );
333
- return this.#sortedLibIndices;
334
- }
335
- static async fromExecutor(exec, { refresh } = {}) {
336
- const existingLibInfo = this.libInfos.get(exec.name);
337
- if (existingLibInfo && !refresh)
338
- return existingLibInfo;
339
- const scanResult = await super.getScanResult(exec);
340
- await Promise.all(
341
- scanResult.libDeps.filter((libName) => !this.loadedLibs.has(libName)).map(async (libName) => {
342
- this.loadedLibs.add(libName);
343
- const libExecutor = import_executors.LibExecutor.from(exec, libName);
344
- this.libInfos.set(libName, await LibInfo.fromExecutor(libExecutor));
345
- })
346
- );
347
- const libInfo = new LibInfo(exec, scanResult);
348
- this.libInfos.set(exec.name, libInfo);
349
- this.#sortedLibIndices = null;
350
- return libInfo;
351
- }
352
- constructor(exec, scanResult) {
353
- super(scanResult);
354
- this.exec = exec;
355
- this.akanConfig = scanResult.akanConfig;
356
- }
357
- getScanResult() {
358
- return this.scanResult;
359
- }
360
- #sortedLibs = null;
361
- #getSortedLibs() {
362
- if (this.#sortedLibs)
363
- return this.#sortedLibs;
364
- const libs = LibInfo.getSortedLibIndices();
365
- this.#sortedLibs = this.scanResult.libDeps.sort((libNameA, libNameB) => {
366
- const indexA = libs.get(libNameA);
367
- const indexB = libs.get(libNameB);
368
- if (indexA === void 0 || indexB === void 0)
369
- throw new Error(`LibInfo not found: ${libNameA} or ${libNameB}`);
370
- return indexA - indexB;
371
- });
372
- return this.#sortedLibs;
373
- }
374
- getLibs() {
375
- return this.#getSortedLibs();
376
- }
377
- getLibInfo(libName) {
378
- if (!this.getScanResult().libDeps.includes(libName))
379
- return void 0;
380
- const libSet = new Set(this.#getSortedLibs());
381
- if (!libSet.has(libName))
382
- throw new Error(`LibInfo is invalid: ${libName}`);
383
- return LibInfo.libInfos.get(libName);
384
- }
385
- getLibInfos() {
386
- return new Map(
387
- this.#getSortedLibs().map((libName) => {
388
- const libInfo = LibInfo.libInfos.get(libName);
389
- if (!libInfo)
390
- throw new Error(`LibInfo not found: ${libName}`);
391
- return [libName, libInfo];
392
- })
393
- );
394
- }
395
- }
396
- class PkgInfo {
397
- exec;
398
- name;
399
- scanResult;
400
- static async getScanResult(exec) {
401
- const tsconfig = exec.getTsConfig();
402
- const rootPackageJson = exec.workspace.getPackageJson();
403
- const gitignorePatterns = exec.workspace.getGitignorePatterns();
404
- const scanner = new import_dependencyScanner.TypeScriptDependencyScanner(exec.cwdPath, {
405
- workspaceRoot: exec.workspace.cwdPath,
406
- tsconfig,
407
- rootPackageJson,
408
- gitignorePatterns
409
- });
410
- const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
411
- const pkgPathSet = new Set(
412
- Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path2) => tsconfig.compilerOptions.paths?.[path2]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path2) => path2.replace("/*", ""))
413
- );
414
- const [npmDepSet, pkgPathDepSet] = await scanner.getImportSets([npmSet, pkgPathSet]);
415
- const pkgDeps = [...pkgPathDepSet].map((path2) => {
416
- const pathSplitLength = path2.split("/").length;
417
- return (tsconfig.compilerOptions.paths?.[path2]?.[0] ?? "*").split("/").slice(1, 1 + pathSplitLength).join("/");
418
- }).filter((pkg) => pkg !== this.name);
419
- const pkgScanResult = {
420
- name: this.name,
421
- pkgDeps,
422
- dependencies: [...npmDepSet]
423
- };
424
- return pkgScanResult;
425
- }
426
- static #pkgInfos = /* @__PURE__ */ new Map();
427
- static async fromExecutor(exec, options = {}) {
428
- const existingPkgInfo = this.#pkgInfos.get(exec.name);
429
- if (existingPkgInfo && !options.refresh)
430
- return existingPkgInfo;
431
- const scanResult = await this.getScanResult(exec);
432
- const pkgInfo = new PkgInfo(exec, scanResult);
433
- this.#pkgInfos.set(exec.name, pkgInfo);
434
- return pkgInfo;
435
- }
436
- constructor(exec, scanResult) {
437
- this.exec = exec;
438
- this.name = exec.name;
439
- this.scanResult = scanResult;
440
- }
441
- getScanResult() {
442
- return this.scanResult;
443
- }
444
- }
445
- class WorkspaceInfo {
446
- constructor(appInfos = /* @__PURE__ */ new Map(), libInfos = /* @__PURE__ */ new Map(), pkgInfos = /* @__PURE__ */ new Map()) {
447
- this.appInfos = appInfos;
448
- this.libInfos = libInfos;
449
- this.pkgInfos = pkgInfos;
450
- }
451
- static #workspaceInfos = /* @__PURE__ */ new Map();
452
- static async fromExecutor(exec, options = {}) {
453
- const existingWorkspaceInfo = this.#workspaceInfos.get(exec.name);
454
- if (existingWorkspaceInfo && !options.refresh)
455
- return existingWorkspaceInfo;
456
- const [appNames, libNames, pkgNames] = await Promise.all([exec.getApps(), exec.getLibs(), exec.getPkgs()]);
457
- const [appInfos, libInfos, pkgInfos] = await Promise.all([
458
- Promise.all(
459
- appNames.map(async (appName) => {
460
- const app = import_executors.AppExecutor.from(exec, appName);
461
- return await app.scan();
462
- })
463
- ),
464
- Promise.all(
465
- libNames.map(async (libName) => {
466
- const lib = import_executors.LibExecutor.from(exec, libName);
467
- return await lib.scan();
468
- })
469
- ),
470
- Promise.all(
471
- pkgNames.map(async (pkgName) => {
472
- return await import_executors.PkgExecutor.from(exec, pkgName).scan();
473
- })
474
- )
475
- ]);
476
- const workspaceInfo = new WorkspaceInfo(
477
- new Map(appInfos.map((app) => [app.exec.name, app])),
478
- new Map(libInfos.map((lib) => [lib.exec.name, lib])),
479
- new Map(pkgInfos.map((pkg) => [pkg.exec.name, pkg]))
480
- );
481
- this.#workspaceInfos.set(exec.name, workspaceInfo);
482
- return workspaceInfo;
483
- }
484
- }
485
- // Annotate the CommonJS export names for ESM import in node:
486
- 0 && (module.exports = {
487
- AppInfo,
488
- LibInfo,
489
- PkgInfo,
490
- WorkspaceInfo
491
- });
@@ -1,46 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var selectModel_exports = {};
29
- __export(selectModel_exports, {
30
- selectModel: () => selectModel
31
- });
32
- module.exports = __toCommonJS(selectModel_exports);
33
- var import_prompts = require("@inquirer/prompts");
34
- var import_fs = __toESM(require("fs"));
35
- const selectModel = async (modulePath) => {
36
- const modelNames = import_fs.default.readdirSync(`${modulePath}/lib`).filter((dir) => !dir.includes(".") && !dir.startsWith("_"));
37
- const modelName = await (0, import_prompts.select)({
38
- message: "Select the model to create the unit for",
39
- choices: modelNames.map((name) => ({ name, value: name }))
40
- });
41
- return modelName;
42
- };
43
- // Annotate the CommonJS export names for ESM import in node:
44
- 0 && (module.exports = {
45
- selectModel
46
- });
@@ -1,93 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var spinner_exports = {};
29
- __export(spinner_exports, {
30
- Spinner: () => Spinner
31
- });
32
- module.exports = __toCommonJS(spinner_exports);
33
- var import_ora = __toESM(require("ora"));
34
- class Spinner {
35
- static padding = 12;
36
- spinner;
37
- stopWatch = null;
38
- startAt = /* @__PURE__ */ new Date();
39
- prefix;
40
- message;
41
- enableSpin;
42
- constructor(message, { prefix = "", indent = 0, enableSpin = true } = {}) {
43
- Spinner.padding = Math.max(Spinner.padding, prefix.length);
44
- this.prefix = prefix;
45
- this.message = message;
46
- this.spinner = (0, import_ora.default)(message);
47
- this.spinner.prefixText = prefix.padStart(Spinner.padding, " ");
48
- this.spinner.indent = indent;
49
- this.enableSpin = enableSpin;
50
- }
51
- start() {
52
- this.startAt = /* @__PURE__ */ new Date();
53
- if (this.enableSpin) {
54
- this.spinner.start();
55
- this.stopWatch = setInterval(() => {
56
- this.spinner.prefixText = this.prefix.padStart(Spinner.padding, " ");
57
- this.spinner.text = `${this.message} (${this.#getElapsedTimeStr()})`;
58
- }, 1e3);
59
- } else
60
- this.spinner.info();
61
- return this;
62
- }
63
- succeed(message) {
64
- this.spinner.succeed(`${message} (${this.#getElapsedTimeStr()})`);
65
- this.#reset();
66
- }
67
- fail(message) {
68
- this.spinner.fail(`${message} (${this.#getElapsedTimeStr()})`);
69
- this.#reset();
70
- }
71
- isSpinning() {
72
- return this.spinner.isSpinning;
73
- }
74
- #reset() {
75
- if (this.stopWatch)
76
- clearInterval(this.stopWatch);
77
- this.stopWatch = null;
78
- }
79
- #getElapsedTimeStr() {
80
- const ms = (/* @__PURE__ */ new Date()).getTime() - this.startAt.getTime();
81
- if (ms < 1e3)
82
- return `${ms}ms`;
83
- const s = Math.floor(ms / 1e3);
84
- if (s < 60)
85
- return `${s}s`;
86
- const m = Math.floor(s / 60);
87
- return `${m}m ${s % 60}s`;
88
- }
89
- }
90
- // Annotate the CommonJS export names for ESM import in node:
91
- 0 && (module.exports = {
92
- Spinner
93
- });
@@ -1,62 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var streamAi_exports = {};
19
- __export(streamAi_exports, {
20
- streamAi: () => streamAi
21
- });
22
- module.exports = __toCommonJS(streamAi_exports);
23
- var import_prompts = require("@langchain/core/prompts");
24
- var import_runnables = require("@langchain/core/runnables");
25
- var import_openai = require("@langchain/openai");
26
- const streamAi = async (question, callback = (chunk) => {
27
- process.stdout.write(chunk);
28
- }) => {
29
- const createStreamingModel = (apiKey = process.env.DEEPSEEK_API_KEY) => {
30
- if (!apiKey)
31
- throw new Error(`process.env.DEEPSEEK_API_KEY is not set`);
32
- return new import_openai.ChatOpenAI({
33
- modelName: "deepseek-reasoner",
34
- temperature: 0.7,
35
- streaming: true,
36
- // Enable streaming
37
- configuration: { baseURL: "https://api.deepseek.com/v1", apiKey }
38
- });
39
- };
40
- const createProcessingChain = () => {
41
- return import_runnables.RunnableSequence.from([import_prompts.PromptTemplate.fromTemplate(`Answer concisely: {question}`), createStreamingModel()]);
42
- };
43
- try {
44
- const chain = createProcessingChain();
45
- const stream = await chain.stream({ question });
46
- let fullResponse = "";
47
- for await (const chunk of stream) {
48
- const content = chunk.content;
49
- if (typeof content === "string") {
50
- fullResponse += content;
51
- callback(content);
52
- }
53
- }
54
- return { content: fullResponse };
55
- } catch (error) {
56
- throw new Error("Failed to stream response");
57
- }
58
- };
59
- // Annotate the CommonJS export names for ESM import in node:
60
- 0 && (module.exports = {
61
- streamAi
62
- });