@akanjs/cli 3.0.0-beta.3 → 3.0.0-beta.30

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/.build-stamp +1 -1
  2. package/CodeAgent-xnfyyz8h.js +9 -0
  3. package/CodeAgentRpcHost-p7h6n2hp.js +7 -0
  4. package/CodeAgentRpcListener-7p7z5dd7.js +97 -0
  5. package/CodeTui-h66xb1fh.js +1457 -0
  6. package/README.md +3 -0
  7. package/TunnelShare-cwh9ezsm.js +9 -0
  8. package/{agent.command-d2gfxfck.js → agent.command-c4v7kjff.js} +8 -9
  9. package/akanCode.js +102 -0
  10. package/application.command-yzsswrz6.js +241 -0
  11. package/{applicationBuildRunner-kxwbssgn.js → applicationBuildRunner-qkt6spd5.js} +121 -77
  12. package/buildBatch.proc.js +120 -32
  13. package/cloud.command-v8h688jc.js +95 -0
  14. package/cloud.script-yct1sk4k.js +20 -0
  15. package/code.command-jff3tw7y.js +154 -0
  16. package/commandManifest.json +1 -1
  17. package/consoleToStderr-h5bryj94.js +7 -0
  18. package/context.command-y5sevk3c.js +48 -0
  19. package/context.runner-90hsmacr.js +21 -0
  20. package/{dependencyScanner-shs82ynp.js → dependencyScanner-06z2dmrr.js} +2 -2
  21. package/{devTui-40ggmd99.js → devTui-q7k7bakd.js} +122 -40
  22. package/fileSys-wzzrntkw.js +9 -0
  23. package/guideline.command-11cndccb.js +42 -0
  24. package/guidelines/agentRule/agentRule.instruction.md +209 -33
  25. package/guidelines/conventions/conventions.instruction.md +143 -41
  26. package/guidelines/fieldRule/fieldRule.instruction.md +1 -0
  27. package/guidelines/mcpRule/mcpRule.instruction.md +7 -5
  28. package/guidelines/queryRule/queryRule.instruction.md +21 -7
  29. package/guidelines/runtimeRule/runtimeRule.instruction.md +268 -6
  30. package/guidelines/ssrRule/ssrRule.instruction.md +4 -2
  31. package/guidelines/transportRule/transportRule.instruction.md +51 -0
  32. package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +20 -0
  33. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +66 -3
  34. package/incrementalBuilder.proc.js +564 -109
  35. package/{index-fz5q3gd7.js → index-0ncc0mbk.js} +10 -17
  36. package/index-167c77aq.js +69 -0
  37. package/{index-kcxmv48c.js → index-2ahj896a.js} +45 -79
  38. package/index-2wc41k5w.js +49 -0
  39. package/{index-j9yhg404.js → index-35mmm9ca.js} +4 -7
  40. package/{index-a64esmtb.js → index-376gpdds.js} +523 -1022
  41. package/index-3hx1z96c.js +87 -0
  42. package/{index-v0qh106m.js → index-3rh7thcx.js} +961 -892
  43. package/{index-hwkygn9s.js → index-48k96p55.js} +325 -36
  44. package/{index-q0y2jq9j.js → index-52w0fvh8.js} +21 -4
  45. package/index-5rp0h6na.js +1119 -0
  46. package/index-6x9p8dpb.js +4300 -0
  47. package/index-7md2g9vw.js +6 -0
  48. package/index-8tv7356t.js +700 -0
  49. package/index-94s080qm.js +266 -0
  50. package/index-9dp031by.js +12 -0
  51. package/{index-ws5e0j51.js → index-a4s954kq.js} +43 -26
  52. package/{index-3d9y066c.js → index-bjwxs904.js} +9 -8
  53. package/{index-ne2qy0nk.js → index-bxmejydw.js} +12 -12
  54. package/index-c6eggbee.js +123 -0
  55. package/index-d2242ksy.js +99 -0
  56. package/{index-92zztqy1.js → index-dy0jx9ay.js} +2 -17
  57. package/{index-259dsnz3.js → index-gxamdf18.js} +5 -8
  58. package/{index-4edzf1gr.js → index-hf6f4xnb.js} +77 -150
  59. package/{index-by5gpp8x.js → index-hj6w4ka1.js} +2 -1
  60. package/{index-gyd220p2.js → index-hmdq5pqm.js} +554 -577
  61. package/{index-600zhnve.js → index-hqd0h1pb.js} +75 -203
  62. package/index-kb16nzyt.js +997 -0
  63. package/index-mk3b9rk1.js +2729 -0
  64. package/{index-2tv3fdx4.js → index-n3jk2501.js} +1205 -1458
  65. package/index-p6pbz9n5.js +25 -0
  66. package/{index-zry5nz81.js → index-qcejqgts.js} +51 -30
  67. package/{index-7737gxcp.js → index-rtwhw4aq.js} +107 -241
  68. package/{index-pnqbkf5p.js → index-se643zvp.js} +6 -2
  69. package/index-tsb0f8ya.js +53 -0
  70. package/{index-ktb5njgy.js → index-tzc1gtrg.js} +49 -99
  71. package/index-wa5jbxj1.js +760 -0
  72. package/index-wfwgcnyc.js +187 -0
  73. package/{index-mak3cd28.js → index-xb7qhxa8.js} +137 -255
  74. package/{index-h7yw2z9n.js → index-zzvvc845.js} +8 -14
  75. package/index.js +23 -22
  76. package/{library.command-nbsky672.js → library.command-n9kp7yms.js} +4 -5
  77. package/{localRegistry.command-yeq57wjr.js → localRegistry.command-jx6kxt2x.js} +23 -42
  78. package/{module.command-29vqzrh8.js → module.command-q2xjf6cx.js} +8 -11
  79. package/{package.command-axv0abmn.js → package.command-q5a3nsw5.js} +6 -7
  80. package/package.json +15 -7
  81. package/{page.command-vs9s3zrh.js → page.command-ppenrxjn.js} +4 -5
  82. package/{primitive.command-cbxmqbtc.js → primitive.command-dvgg8nem.js} +9 -22
  83. package/prompter-76k56b37.js +8 -0
  84. package/{quality.command-gmbs7nws.js → quality.command-pz7kg3pc.js} +205 -377
  85. package/{recipeScanner-fpagtgc1.js → recipeScanner-4b69ybe0.js} +1 -1
  86. package/{repair.command-bqsjptsj.js → repair.command-a6py9xvz.js} +11 -35
  87. package/{routeSourceValidator-apyqw7wk.js → routeSourceValidator-7ycnfz0e.js} +0 -6
  88. package/{scalar.command-6k1vhe9s.js → scalar.command-7f3xfpen.js} +7 -10
  89. package/skills/akan-code/SKILL.md +130 -0
  90. package/skills/akan-debug/SKILL.md +42 -0
  91. package/skills/akan-deps/SKILL.md +50 -0
  92. package/skills/akan-err/SKILL.md +39 -0
  93. package/skills/akan-module/SKILL.md +45 -0
  94. package/skills/akan-scaffold/SKILL.md +76 -0
  95. package/skills/akan-scalar/SKILL.md +52 -0
  96. package/skills/akan-service/SKILL.md +34 -0
  97. package/skills/akan-store/SKILL.md +67 -0
  98. package/skills/akan-ui/SKILL.md +63 -0
  99. package/skills/akan-validate/SKILL.md +44 -0
  100. package/{subspace.command-fwjfcts7.js → subspace.command-z7nqs508.js} +138 -67
  101. package/templates/__scalar/__model__/__model__.abstract.md.template +8 -0
  102. package/templates/appSample/lib/__scalar/workHistory/workHistory.abstract.ts +8 -39
  103. package/templates/appSample/lib/_noti/noti.abstract.ts +6 -29
  104. package/templates/appSample/lib/task/task.abstract.ts +12 -32
  105. package/templates/appSample/lib/task/task.signal.spec.ts +15 -18
  106. package/templates/appSample/lib/task/task.signal.test.ts +15 -1
  107. package/templates/appSample/lib/task/task.signal.ts +1 -1
  108. package/templates/appSample/srvkit/{AuthGuard.ts → guards.ts} +7 -4
  109. package/templates/appSample/srvkit/{SessionInternalArg.ts → internalArgs.ts} +6 -4
  110. package/templates/client.ts +7 -30
  111. package/templates/crudPages/[__model__Id]/edit/page.tsx +2 -1
  112. package/templates/crudPages/[__model__Id]/page.tsx +2 -1
  113. package/templates/crudPages/new/page.tsx +2 -1
  114. package/templates/crudPages/page.tsx +2 -1
  115. package/templates/crudSinglePage/page.tsx +2 -1
  116. package/templates/lib/__lib/lib.dictionary.ts +0 -2
  117. package/templates/lib/__lib/lib.document.ts +0 -2
  118. package/templates/lib/sig.ts +8 -30
  119. package/templates/localDev/docker-compose.yaml.template +3 -14
  120. package/templates/module/__model__.signal.ts +12 -4
  121. package/templates/pkgRoot/tsconfig.json.template +2 -7
  122. package/templates/server.ts +1 -3
  123. package/templates/service/__model__.abstract.md.template +8 -0
  124. package/templates/workspaceRoot/.gitignore.template +0 -1
  125. package/templates/workspaceRoot/package.json.template +1 -3
  126. package/tunnel.command-zy4wbcgt.js +129 -0
  127. package/{typeChecker-3xgrzc2v.js → typeChecker-px49mezc.js} +1 -1
  128. package/typecheck.proc.js +1 -1
  129. package/workflow.command-f142t17s.js +79 -0
  130. package/{workspace.command-8s050m0h.js → workspace.command-gpk1149x.js} +77 -109
  131. package/abstractCompactor-mjh5ppsq.js +0 -101
  132. package/application.command-pj2m7584.js +0 -204
  133. package/applicationReleasePackager-4yasxwv9.js +0 -244
  134. package/capacitorApp-36rbr858.js +0 -12
  135. package/cloud.command-jshwdq22.js +0 -93
  136. package/context.command-ez8a0zyz.js +0 -80
  137. package/devTuiView-c08ccbat.js +0 -9
  138. package/getDirname-dr3jz1xg.js +0 -7
  139. package/guideline.command-xmqwx8zm.js +0 -359
  140. package/guidelines/agentRule/agentRule.generate.json +0 -31
  141. package/guidelines/componentRule/componentRule.generate.json +0 -31
  142. package/guidelines/conventions/conventions.generate.json +0 -25
  143. package/guidelines/cssRule/cssRule.generate.json +0 -31
  144. package/guidelines/docPageRule/docPageRule.generate.json +0 -31
  145. package/guidelines/docPageRule/docPageRule.instruction.md +0 -25
  146. package/guidelines/docSyncRule/docSyncRule.generate.json +0 -31
  147. package/guidelines/docSyncRule/docSyncRule.instruction.md +0 -25
  148. package/guidelines/enumConstant/enumConstant.generate.json +0 -31
  149. package/guidelines/enumConstant/enumConstant.instruction.md +0 -28
  150. package/guidelines/fieldRule/fieldRule.generate.json +0 -31
  151. package/guidelines/framework/framework.generate.json +0 -32
  152. package/guidelines/mcpRule/mcpRule.generate.json +0 -35
  153. package/guidelines/modelConstant/modelConstant.generate.json +0 -32
  154. package/guidelines/modelDictionary/modelDictionary.generate.json +0 -32
  155. package/guidelines/modelDocument/modelDocument.generate.json +0 -31
  156. package/guidelines/modelService/modelService.generate.json +0 -31
  157. package/guidelines/modelSignal/modelSignal.generate.json +0 -31
  158. package/guidelines/modelStore/modelStore.generate.json +0 -31
  159. package/guidelines/modelTemplate/modelTemplate.generate.json +0 -31
  160. package/guidelines/modelUnit/modelUnit.generate.json +0 -31
  161. package/guidelines/modelUtil/modelUtil.generate.json +0 -31
  162. package/guidelines/modelView/modelView.generate.json +0 -31
  163. package/guidelines/modelZone/modelZone.generate.json +0 -31
  164. package/guidelines/moduleCodegen/moduleCodegen.generate.json +0 -31
  165. package/guidelines/moduleCodegen/moduleCodegen.instruction.md +0 -28
  166. package/guidelines/moduleOverview/moduleOverview.generate.json +0 -31
  167. package/guidelines/queryRule/queryRule.generate.json +0 -31
  168. package/guidelines/recipeRule/recipeRule.generate.json +0 -31
  169. package/guidelines/runtimeRule/runtimeRule.generate.json +0 -25
  170. package/guidelines/scalarConstant/scalarConstant.generate.json +0 -32
  171. package/guidelines/scalarDictionary/scalarDictionary.generate.json +0 -32
  172. package/guidelines/scalarModule/scalarModule.generate.json +0 -31
  173. package/guidelines/sharedUiUsage/sharedUiUsage.generate.json +0 -31
  174. package/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +0 -25
  175. package/guidelines/ssrRule/ssrRule.generate.json +0 -31
  176. package/guidelines/transportRule/transportRule.generate.json +0 -31
  177. package/guidelines/utilUiUsage/utilUiUsage.generate.json +0 -31
  178. package/guidelines/utilUiUsage/utilUiUsage.instruction.md +0 -25
  179. package/guidelines/workspaceOnboarding/workspaceOnboarding.generate.json +0 -24
  180. package/guidelines/workspaceRecipes/workspaceRecipes.generate.json +0 -33
  181. package/index-2hq52jq3.js +0 -465
  182. package/index-47pj3aee.js +0 -76
  183. package/index-6wwzs1bc.js +0 -7
  184. package/index-8pm30m73.js +0 -841
  185. package/index-kn1h7p1x.js +0 -560
  186. package/index-meh558jy.js +0 -65
  187. package/index-rwg2aa4f.js +0 -229
  188. package/index-w8kmx1b6.js +0 -2176
  189. package/index-wt7qrtd4.js +0 -1516
  190. package/templates/__scalar/__model__/__model__.abstract.md +0 -28
  191. package/templates/module/__model__.abstract.md +0 -28
  192. package/templates/service/__model__.abstract.md +0 -28
  193. package/templates/workspaceRoot/patches/react-dom@19.2.7.patch.template +0 -62
  194. package/workflow.command-nwpcdc8p.js +0 -107
@@ -5,33 +5,26 @@ import {
5
5
  writeGeneratedSyncState,
6
6
  createRepairReport,
7
7
  renderRepairReport
8
- } from "./index-gyd220p2.js";
8
+ } from "./index-hmdq5pqm.js";
9
9
  import {
10
10
  AkanContextAnalyzer
11
- } from "./index-ktb5njgy.js";
11
+ } from "./index-tzc1gtrg.js";
12
12
  import {
13
13
  runner
14
- } from "./index-mak3cd28.js";
14
+ } from "./index-xb7qhxa8.js";
15
15
 
16
16
  // pkgs/@akanjs/cli/repair/repair.runner.ts
17
- var commandForShell = (command) => command.startsWith("akan ") ? `bun run ${command}` : command;
17
+ var spawnShell = async (workspace, command) => await workspace.spawn("bash", ["-lc", command.startsWith("akan ") ? `bun run ${command}` : command], {
18
+ cwd: workspace.workspaceRoot
19
+ });
18
20
  var defaultExecutor = (workspace) => async (command) => {
21
+ const base = { command: command.command, reason: command.reason };
19
22
  try {
20
- const stdout = await workspace.spawn("bash", ["-lc", commandForShell(command.command)], {
21
- cwd: workspace.workspaceRoot
22
- });
23
- return {
24
- command: command.command,
25
- reason: command.reason,
26
- status: "passed",
27
- exitCode: 0,
28
- stdout
29
- };
23
+ return { ...base, status: "passed", exitCode: 0, stdout: await spawnShell(workspace, command.command) };
30
24
  } catch (error) {
31
25
  const commandError = error;
32
26
  return {
33
- command: command.command,
34
- reason: command.reason,
27
+ ...base,
35
28
  status: "failed",
36
29
  exitCode: commandError.code ?? 1,
37
30
  stdout: commandError.stdout,
@@ -158,4 +151,4 @@ class RepairRunner extends runner("repair") {
158
151
  }
159
152
  }
160
153
 
161
- export { RepairRunner };
154
+ export { spawnShell, RepairRunner };
@@ -0,0 +1,69 @@
1
+ // @bun
2
+ import {
3
+ jsonText
4
+ } from "./index-hmdq5pqm.js";
5
+ import {
6
+ akanMcpInstallTargets
7
+ } from "./index-tzc1gtrg.js";
8
+ import {
9
+ script
10
+ } from "./index-xb7qhxa8.js";
11
+ import {
12
+ ContextRunner2
13
+ } from "./index-hqd0h1pb.js";
14
+
15
+ // pkgs/@akanjs/cli/context/context.script.ts
16
+ import { Logger } from "akanjs/common";
17
+ var resolveMcpInstallTargets = (target) => {
18
+ if (!target || target === "all")
19
+ return [...akanMcpInstallTargets];
20
+ if (akanMcpInstallTargets.includes(target))
21
+ return [target];
22
+ throw new Error(`Unknown MCP install target: ${target}. Use cursor, claude, codex, or all.`);
23
+ };
24
+ var mcpTargetLabels = {
25
+ cursor: "Cursor",
26
+ claude: "Claude Code",
27
+ codex: "Codex"
28
+ };
29
+
30
+ class ContextScript extends script("context", [ContextRunner2]) {
31
+ async context(workspace, options = {}) {
32
+ Logger.rawLog(await this.contextRunner.getContext(workspace, options));
33
+ }
34
+ async doctor(workspace, options = {}) {
35
+ Logger.rawLog(await this.contextRunner.doctor(workspace, options));
36
+ }
37
+ async mcpInstall(workspace, target, { force = false, mode = "apply" } = {}) {
38
+ const targets = resolveMcpInstallTargets(target);
39
+ const written = [];
40
+ for (const t of targets) {
41
+ const configPath = await this.contextRunner.installMcp(workspace, t, { force, mode });
42
+ written.push(`${mcpTargetLabels[t]}: ${configPath}`);
43
+ }
44
+ Logger.rawLog(`Akan MCP server installed (${mode} mode):
45
+ ${written.map((line) => `- ${line}`).join(`
46
+ `)}`);
47
+ }
48
+ async mcp(workspace, { mode = "apply" } = {}) {
49
+ await this.contextRunner.runMcp(workspace, { mode });
50
+ }
51
+ async mcpCall(workspace, tool, {
52
+ mode = "readonly",
53
+ args = null,
54
+ format = "json"
55
+ } = {}) {
56
+ let parsedArgs = {};
57
+ if (args) {
58
+ const parsed = JSON.parse(args);
59
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
60
+ throw new Error("MCP call args must be a JSON object.");
61
+ }
62
+ parsedArgs = parsed;
63
+ }
64
+ const result = await this.contextRunner.callMcpTool(workspace, tool, parsedArgs, { mode });
65
+ Logger.rawLog(format === "json" ? jsonText(result) : String(result));
66
+ }
67
+ }
68
+
69
+ export { ContextScript };
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
- FileSys
4
- } from "./index-q0y2jq9j.js";
3
+ FileSys2
4
+ } from "./index-52w0fvh8.js";
5
5
 
6
6
  // pkgs/@akanjs/devkit/dependencyScanner.ts
7
7
  import { builtinModules } from "module";
@@ -10,7 +10,10 @@ import ignore from "ignore";
10
10
  import ts from "typescript";
11
11
  var testFileRegex = /\.(?:test|spec)\.[cm]?[tj]sx?$/;
12
12
  var skipDirs = ["node_modules", "dist", "build", ".git", ".next", "public", "ios", "android", "__fixtures__"];
13
- var isSkippedPath = (filePath) => skipDirs.some((dir) => filePath.includes(`/${dir}/`) || filePath.startsWith(`${dir}/`));
13
+ var isSkippedPath = (filePath) => {
14
+ const posixPath = filePath.split(path.sep).join("/");
15
+ return skipDirs.some((dir) => posixPath.includes(`/${dir}/`) || posixPath.startsWith(`${dir}/`));
16
+ };
14
17
  var builtinModuleSet = new Set([...builtinModules, ...builtinModules.map((mod) => `node:${mod}`)]);
15
18
  var stripShebang = (source) => source.replace(/^#!.*(?:\r?\n|$)/, "");
16
19
 
@@ -54,24 +57,21 @@ class TypeScriptDependencyScanner2 {
54
57
  async getPackageBuildDependencies(projectName) {
55
58
  const runtimeDeps = new Set;
56
59
  const devDeps = new Set;
57
- const sourceFiles = await this.#findTypeScriptFiles(this.#directory, {
58
- excludeBuildFiles: true,
59
- excludeTestFiles: true
60
- });
61
- const cssFiles = await this.#findCssFiles(this.#directory);
60
+ const sourceFiles = await this.#findFiles("**/*.{ts,tsx}", { excludeBuildFiles: true, excludeTestFiles: true });
61
+ const cssFiles = await this.#findFiles("**/*.css");
62
62
  for (const filePath of sourceFiles) {
63
- const fileContent = await FileSys.readText(filePath);
63
+ const fileContent = await FileSys2.readText(filePath);
64
64
  const { imports, typeImports } = this.#extractImports(fileContent, filePath);
65
65
  this.#addNormalizedImports(runtimeDeps, imports, projectName);
66
66
  this.#addNormalizedImports(devDeps, typeImports, projectName);
67
67
  }
68
68
  for (const filePath of cssFiles) {
69
- const fileContent = await FileSys.readText(filePath);
69
+ const fileContent = await FileSys2.readText(filePath);
70
70
  this.#addNormalizedImports(runtimeDeps, this.#extractCssPluginImports(fileContent), projectName);
71
71
  }
72
72
  const buildFilePath = path.join(this.#directory, "build.ts");
73
- if (await FileSys.fileExists(buildFilePath)) {
74
- const fileContent = await FileSys.readText(buildFilePath);
73
+ if (await FileSys2.fileExists(buildFilePath)) {
74
+ const fileContent = await FileSys2.readText(buildFilePath);
75
75
  const { imports, typeImports } = this.#extractImports(fileContent, buildFilePath);
76
76
  this.#addNormalizedImports(devDeps, [...imports, ...typeImports], projectName);
77
77
  }
@@ -95,7 +95,7 @@ class TypeScriptDependencyScanner2 {
95
95
  if (!await Bun.file(packageJsonPath).exists())
96
96
  return false;
97
97
  try {
98
- const packageJson = await FileSys.readJson(packageJsonPath);
98
+ const packageJson = await FileSys2.readJson(packageJsonPath);
99
99
  return packageJson.name === dep && !!packageJson.version;
100
100
  } catch {
101
101
  return false;
@@ -106,27 +106,21 @@ class TypeScriptDependencyScanner2 {
106
106
  return this.#getImportSetsFromDependencies(depSets, fileDependencies);
107
107
  }
108
108
  #getImportSetsFromDependencies(depSets, fileDependencies) {
109
- const importedDepSets = new Array(depSets.length);
110
- for (let i = 0;i < depSets.length; i++)
111
- importedDepSets[i] = new Set;
112
- fileDependencies.forEach((imps) => {
113
- imps.forEach((imp) => {
109
+ const importedDepSets = depSets.map(() => new Set);
110
+ for (const imps of fileDependencies.values())
111
+ for (const imp of imps) {
114
112
  if (imp.startsWith("."))
115
- return;
116
- const moduleName = imp;
117
- const moduleNameParts = moduleName.split("/");
118
- const subModuleLength = moduleNameParts.length;
119
- for (let i = 0;i < subModuleLength; i++) {
120
- const importName = moduleNameParts.slice(0, i + 1).join("/");
121
- for (let j = 0;j < depSets.length; j++) {
122
- if (depSets[j]?.has(importName)) {
123
- importedDepSets[j]?.add(importName);
124
- return;
125
- }
126
- }
113
+ continue;
114
+ const parts = imp.split("/");
115
+ for (let length = 1;length <= parts.length; length++) {
116
+ const importName = parts.slice(0, length).join("/");
117
+ const setIndex = depSets.findIndex((depSet) => depSet.has(importName));
118
+ if (setIndex === -1)
119
+ continue;
120
+ importedDepSets[setIndex]?.add(importName);
121
+ break;
127
122
  }
128
- });
129
- });
123
+ }
130
124
  return importedDepSets;
131
125
  }
132
126
  async getDependencies() {
@@ -134,43 +128,25 @@ class TypeScriptDependencyScanner2 {
134
128
  this.#fileRuntimeDependencies.clear();
135
129
  this.#fileTypeDependencies.clear();
136
130
  this.#visitedFiles.clear();
137
- const files = await this.#findTypeScriptFiles(this.#directory);
138
- for (const file of files)
131
+ for (const file of await this.#findFiles("**/*.{ts,tsx}"))
139
132
  await this.#analyzeFile(file, this.#directory);
140
133
  return this.#fileDependencies;
141
134
  }
142
- async#findTypeScriptFiles(directory, {
135
+ async#findFiles(pattern, {
143
136
  excludeBuildFiles = false,
144
137
  excludeTestFiles = false
145
138
  } = {}) {
146
139
  const files = [];
147
- const glob = new Bun.Glob("**/*.{ts,tsx}");
148
- for await (const filePath of glob.scan({ cwd: directory, onlyFiles: true })) {
140
+ for await (const filePath of new Bun.Glob(pattern).scan({ cwd: this.#directory, onlyFiles: true })) {
149
141
  if (isSkippedPath(filePath))
150
142
  continue;
151
143
  if (excludeBuildFiles && filePath === "build.ts")
152
144
  continue;
153
145
  if (excludeTestFiles && testFileRegex.test(filePath))
154
146
  continue;
155
- const fullPath = path.join(directory, filePath);
156
- const relativePath = path.relative(this.#workspaceRoot, fullPath);
157
- if (this.#ig.ignores(relativePath))
158
- continue;
159
- files.push(fullPath);
160
- }
161
- return files;
162
- }
163
- async#findCssFiles(directory) {
164
- const files = [];
165
- const glob = new Bun.Glob("**/*.css");
166
- for await (const filePath of glob.scan({ cwd: directory, onlyFiles: true })) {
167
- if (isSkippedPath(filePath))
168
- continue;
169
- const fullPath = path.join(directory, filePath);
170
- const relativePath = path.relative(this.#workspaceRoot, fullPath);
171
- if (this.#ig.ignores(relativePath))
172
- continue;
173
- files.push(fullPath);
147
+ const fullPath = path.join(this.#directory, filePath);
148
+ if (!this.#ig.ignores(path.relative(this.#workspaceRoot, fullPath)))
149
+ files.push(fullPath);
174
150
  }
175
151
  return files;
176
152
  }
@@ -179,7 +155,7 @@ class TypeScriptDependencyScanner2 {
179
155
  return;
180
156
  this.#visitedFiles.add(filePath);
181
157
  try {
182
- const fileContent = await FileSys.readText(filePath);
158
+ const fileContent = await FileSys2.readText(filePath);
183
159
  const { imports, typeImports } = this.#extractImports(fileContent, filePath);
184
160
  const resolvedImports = await this.#resolveImports(imports, filePath, baseDir);
185
161
  const resolvedTypeImports = await this.#resolveImports(typeImports, filePath, baseDir);
@@ -191,19 +167,17 @@ class TypeScriptDependencyScanner2 {
191
167
  }
192
168
  async#resolveImports(imports, filePath, baseDir) {
193
169
  return await Promise.all(imports.map(async (importPath) => {
194
- if (importPath.startsWith(".")) {
195
- const resolvedPath = `./${path.join(path.relative(baseDir, filePath), importPath)}`;
196
- return await this.#ensureExtension(resolvedPath);
197
- }
198
- return importPath;
170
+ if (!importPath.startsWith("."))
171
+ return importPath;
172
+ return await this.#ensureExtension(`./${path.join(path.relative(baseDir, filePath), importPath)}`);
199
173
  }));
200
174
  }
201
175
  async#ensureExtension(filePath) {
202
- if (await FileSys.fileExists(`${filePath}.ts`))
176
+ if (await FileSys2.fileExists(`${filePath}.ts`))
203
177
  return `${filePath}.ts`;
204
- else if (await FileSys.fileExists(`${filePath}.tsx`))
178
+ else if (await FileSys2.fileExists(`${filePath}.tsx`))
205
179
  return `${filePath}.tsx`;
206
- else if (await FileSys.fileExists(filePath))
180
+ else if (await FileSys2.fileExists(filePath))
207
181
  return filePath;
208
182
  return `${filePath}.ts`;
209
183
  }
@@ -262,22 +236,14 @@ class TypeScriptDependencyScanner2 {
262
236
  `;
263
237
  const projectImports = imports.filter((i) => !i.startsWith("react") && !i.startsWith("@"));
264
238
  const externalImports = imports.filter((i) => i.startsWith("react") || i.startsWith("@"));
265
- if (projectImports.length > 0) {
239
+ if (projectImports.length > 0)
266
240
  graph += ` Project dependencies:
267
- `;
268
- projectImports.forEach((imp) => {
269
- graph += ` \u2192 ${imp}
270
- `;
271
- });
272
- }
273
- if (externalImports.length > 0) {
241
+ ${projectImports.map((imp) => ` \u2192 ${imp}
242
+ `).join("")}`;
243
+ if (externalImports.length > 0)
274
244
  graph += ` External dependencies:
275
- `;
276
- externalImports.forEach((imp) => {
277
- graph += ` \u2192 ${imp}
278
- `;
279
- });
280
- }
245
+ ${externalImports.map((imp) => ` \u2192 ${imp}
246
+ `).join("")}`;
281
247
  graph += `
282
248
  `;
283
249
  }
@@ -0,0 +1,49 @@
1
+ // @bun
2
+ import {
3
+ GlobalConfig,
4
+ CloudApi
5
+ } from "./index-94s080qm.js";
6
+
7
+ // pkgs/@akanjs/cli/tunnel/TunnelShare.ts
8
+ import { TunnelAgent } from "akanjs/server/tunnel";
9
+
10
+ class TunnelShare2 {
11
+ #api;
12
+ #agent;
13
+ grant;
14
+ #closed = false;
15
+ constructor(api, agent, grant) {
16
+ this.#api = api;
17
+ this.#agent = agent;
18
+ this.grant = grant;
19
+ }
20
+ static async open(app, { workspace, host, port, ttlMinutes, onLost }) {
21
+ const api = await CloudApi.fromHost(workspace, host ?? GlobalConfig.akanCloudHost);
22
+ const grant = await api.requestTunnel({ name: app.name, ...ttlMinutes ? { ttlMinutes } : {} });
23
+ const origin = `http://localhost:${port ?? await app.getDevPort()}`;
24
+ const agent = new TunnelAgent({
25
+ gatewayUrl: grant.gatewayUrl,
26
+ token: grant.token,
27
+ hostnames: [grant.hostname],
28
+ origin,
29
+ name: app.name,
30
+ ...onLost ? { onLost } : {}
31
+ });
32
+ await agent.start();
33
+ return new TunnelShare2(api, agent, grant);
34
+ }
35
+ get url() {
36
+ return this.grant.url;
37
+ }
38
+ async close() {
39
+ if (this.#closed)
40
+ return;
41
+ this.#closed = true;
42
+ await this.#agent.stop("cli exited");
43
+ try {
44
+ await this.#api.revokeTunnel(this.grant.code);
45
+ } catch {}
46
+ }
47
+ }
48
+
49
+ export { TunnelShare2 };
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  AppInfo
4
- } from "./index-2tv3fdx4.js";
4
+ } from "./index-n3jk2501.js";
5
5
 
6
6
  // pkgs/@akanjs/devkit/slicePlanner.ts
7
7
  class SlicePlanner {
@@ -65,9 +65,6 @@ class SlicePlanner {
65
65
  constructor(app) {
66
66
  this.#app = app;
67
67
  }
68
- async#trackedFiles(paths) {
69
- return await this.#app.workspace.listGitFiles(paths);
70
- }
71
68
  async#untrackedFiles(paths) {
72
69
  const [tracked, all] = await Promise.all([
73
70
  this.#app.workspace.listGitFiles(paths),
@@ -102,12 +99,12 @@ class SlicePlanner {
102
99
  const libs = appInfo.getLibs();
103
100
  const slicePaths = [`apps/${this.#app.name}`, ...libs.map((lib) => `libs/${lib}`)];
104
101
  const [appFiles, allTracked, untracked, rootPackageJson] = await Promise.all([
105
- this.#trackedFiles([`apps/${this.#app.name}`]),
106
- this.#trackedFiles(["."]),
102
+ this.#app.workspace.listGitFiles([`apps/${this.#app.name}`]),
103
+ this.#app.workspace.listGitFiles(["."]),
107
104
  this.#untrackedFiles(slicePaths),
108
105
  this.#app.workspace.getPackageJson()
109
106
  ]);
110
- const libFiles = Object.fromEntries(await Promise.all(libs.map(async (lib) => [lib, await this.#trackedFiles([`libs/${lib}`])])));
107
+ const libFiles = Object.fromEntries(await Promise.all(libs.map(async (lib) => [lib, await this.#app.workspace.listGitFiles([`libs/${lib}`])])));
111
108
  const rootFiles = allTracked.filter((file) => !this.#isMemberFile(file));
112
109
  const required = SlicePlanner.#requiredDependencies(appInfo);
113
110
  const {