@akanjs/cli 3.0.0-beta.2 → 3.0.0-beta.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 (187) hide show
  1. package/.build-stamp +1 -1
  2. package/CodeAgent-awv258wb.js +9 -0
  3. package/CodeAgentRpcHost-p7h6n2hp.js +7 -0
  4. package/CodeAgentRpcListener-7p7z5dd7.js +97 -0
  5. package/CodeTui-1nqh35ez.js +1457 -0
  6. package/README.md +3 -0
  7. package/TunnelShare-scf4e4pd.js +9 -0
  8. package/{agent.command-d2gfxfck.js → agent.command-1s9ag7sb.js} +8 -9
  9. package/akanCode.js +102 -0
  10. package/{application.command-pj2m7584.js → application.command-49hwy6va.js} +51 -78
  11. package/{applicationBuildRunner-kxwbssgn.js → applicationBuildRunner-ybyp97pv.js} +63 -64
  12. package/{applicationReleasePackager-4yasxwv9.js → applicationReleasePackager-esnrphw8.js} +40 -60
  13. package/buildBatch.proc.js +19 -24
  14. package/{capacitorApp-36rbr858.js → capacitorApp-1synz4en.js} +3 -4
  15. package/cloud.command-d7rqtzt9.js +94 -0
  16. package/cloud.script-bkbpcr96.js +19 -0
  17. package/code.command-nn48xzej.js +154 -0
  18. package/commandManifest.json +1 -1
  19. package/consoleToStderr-h5bryj94.js +7 -0
  20. package/context.command-s3mcmvpa.js +48 -0
  21. package/context.runner-k99nb5pk.js +21 -0
  22. package/{dependencyScanner-shs82ynp.js → dependencyScanner-ye2e6pdz.js} +2 -2
  23. package/{devTui-40ggmd99.js → devTui-q7k7bakd.js} +122 -40
  24. package/fileSys-5ngz93ga.js +9 -0
  25. package/guideline.command-sct4qnt5.js +42 -0
  26. package/guidelines/agentRule/agentRule.instruction.md +206 -25
  27. package/guidelines/conventions/conventions.instruction.md +79 -24
  28. package/guidelines/fieldRule/fieldRule.instruction.md +1 -0
  29. package/guidelines/mcpRule/mcpRule.instruction.md +7 -5
  30. package/guidelines/queryRule/queryRule.instruction.md +17 -7
  31. package/guidelines/runtimeRule/runtimeRule.instruction.md +74 -0
  32. package/guidelines/ssrRule/ssrRule.instruction.md +4 -2
  33. package/guidelines/transportRule/transportRule.instruction.md +51 -0
  34. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +66 -3
  35. package/incrementalBuilder.proc.js +31 -48
  36. package/{index-h7yw2z9n.js → index-0bq14vr1.js} +8 -14
  37. package/index-13ffe9wp.js +69 -0
  38. package/index-22d57v4c.js +266 -0
  39. package/{index-fz5q3gd7.js → index-31yr441d.js} +10 -17
  40. package/index-3hx1z96c.js +87 -0
  41. package/index-3sq321ak.js +53 -0
  42. package/{index-kcxmv48c.js → index-3t7g9e4r.js} +45 -79
  43. package/{index-q0y2jq9j.js → index-5b6tavv3.js} +6 -3
  44. package/{index-47pj3aee.js → index-5e0n4hqx.js} +11 -12
  45. package/{index-259dsnz3.js → index-5pc1qrbv.js} +5 -8
  46. package/index-7md2g9vw.js +6 -0
  47. package/index-8mna0947.js +187 -0
  48. package/{index-zry5nz81.js → index-8sf7wmdr.js} +51 -30
  49. package/{index-2tv3fdx4.js → index-9d9bgcx4.js} +342 -765
  50. package/index-9dp031by.js +12 -0
  51. package/{index-ne2qy0nk.js → index-ahemdr5n.js} +12 -12
  52. package/{index-ws5e0j51.js → index-as7xmyz8.js} +40 -24
  53. package/index-axzjaqve.js +1118 -0
  54. package/{index-3d9y066c.js → index-bjwxs904.js} +9 -8
  55. package/index-c6eggbee.js +123 -0
  56. package/index-d2242ksy.js +99 -0
  57. package/{index-a64esmtb.js → index-ddxvdd1p.js} +169 -305
  58. package/{index-92zztqy1.js → index-dy0jx9ay.js} +2 -17
  59. package/{index-pnqbkf5p.js → index-dzf3r49a.js} +6 -2
  60. package/{index-w8kmx1b6.js → index-fgq75haa.js} +198 -290
  61. package/{index-by5gpp8x.js → index-hj6w4ka1.js} +2 -1
  62. package/{index-hwkygn9s.js → index-khpfpcsd.js} +302 -33
  63. package/{index-wt7qrtd4.js → index-mxav6j3c.js} +93 -232
  64. package/{index-gyd220p2.js → index-myhc3c1j.js} +554 -577
  65. package/{index-600zhnve.js → index-nv5976x3.js} +56 -197
  66. package/index-p6pbz9n5.js +25 -0
  67. package/{index-4edzf1gr.js → index-przybvy5.js} +77 -150
  68. package/index-smme4r47.js +49 -0
  69. package/{index-mak3cd28.js → index-w2zdcw3k.js} +137 -255
  70. package/index-wa5jbxj1.js +760 -0
  71. package/{index-v0qh106m.js → index-ww4z397j.js} +527 -723
  72. package/{index-j9yhg404.js → index-xqjwd384.js} +4 -7
  73. package/{index-7737gxcp.js → index-xqpzbab5.js} +107 -241
  74. package/index-xsjh6nzh.js +2729 -0
  75. package/{index-ktb5njgy.js → index-ygn77a5w.js} +47 -99
  76. package/index-ztp3e73t.js +700 -0
  77. package/index.js +23 -22
  78. package/{library.command-nbsky672.js → library.command-1gx04jgn.js} +4 -5
  79. package/{localRegistry.command-yeq57wjr.js → localRegistry.command-zndxj1q6.js} +22 -42
  80. package/{module.command-29vqzrh8.js → module.command-3waddk95.js} +8 -11
  81. package/{package.command-axv0abmn.js → package.command-zrc7br1y.js} +6 -7
  82. package/package.json +14 -5
  83. package/{page.command-vs9s3zrh.js → page.command-vpjgardh.js} +4 -5
  84. package/{primitive.command-cbxmqbtc.js → primitive.command-sz84tk4t.js} +9 -22
  85. package/prompter-ptaa3nk0.js +8 -0
  86. package/{quality.command-gmbs7nws.js → quality.command-g869hafs.js} +203 -376
  87. package/{recipeScanner-fpagtgc1.js → recipeScanner-4b69ybe0.js} +1 -1
  88. package/{repair.command-bqsjptsj.js → repair.command-chsnjvvv.js} +11 -35
  89. package/{routeSourceValidator-apyqw7wk.js → routeSourceValidator-7ycnfz0e.js} +0 -6
  90. package/{scalar.command-6k1vhe9s.js → scalar.command-2v21newx.js} +7 -10
  91. package/skills/akan-code/SKILL.md +130 -0
  92. package/skills/akan-debug/SKILL.md +42 -0
  93. package/skills/akan-deps/SKILL.md +50 -0
  94. package/skills/akan-err/SKILL.md +39 -0
  95. package/skills/akan-module/SKILL.md +45 -0
  96. package/skills/akan-scaffold/SKILL.md +76 -0
  97. package/skills/akan-scalar/SKILL.md +52 -0
  98. package/skills/akan-service/SKILL.md +34 -0
  99. package/skills/akan-store/SKILL.md +67 -0
  100. package/skills/akan-ui/SKILL.md +63 -0
  101. package/skills/akan-validate/SKILL.md +44 -0
  102. package/{subspace.command-fwjfcts7.js → subspace.command-ckcbwfp1.js} +138 -67
  103. package/templates/__scalar/__model__/__model__.abstract.md.template +8 -0
  104. package/templates/appSample/lib/__scalar/workHistory/workHistory.abstract.ts +8 -39
  105. package/templates/appSample/lib/_noti/noti.abstract.ts +6 -29
  106. package/templates/appSample/lib/task/task.abstract.ts +12 -32
  107. package/templates/appSample/lib/task/task.signal.spec.ts +15 -18
  108. package/templates/appSample/lib/task/task.signal.test.ts +15 -1
  109. package/templates/appSample/lib/task/task.signal.ts +1 -1
  110. package/templates/appSample/srvkit/{AuthGuard.ts → guards.ts} +7 -4
  111. package/templates/appSample/srvkit/{SessionInternalArg.ts → internalArgs.ts} +6 -4
  112. package/templates/client.ts +7 -30
  113. package/templates/crudPages/[__model__Id]/edit/page.tsx +2 -1
  114. package/templates/crudPages/[__model__Id]/page.tsx +2 -1
  115. package/templates/crudPages/new/page.tsx +2 -1
  116. package/templates/crudPages/page.tsx +2 -1
  117. package/templates/crudSinglePage/page.tsx +2 -1
  118. package/templates/lib/__lib/lib.dictionary.ts +0 -2
  119. package/templates/lib/__lib/lib.document.ts +0 -2
  120. package/templates/lib/sig.ts +8 -30
  121. package/templates/localDev/docker-compose.yaml.template +3 -14
  122. package/templates/module/__model__.signal.ts +12 -4
  123. package/templates/pkgRoot/tsconfig.json.template +2 -7
  124. package/templates/server.ts +0 -2
  125. package/templates/service/__model__.abstract.md.template +8 -0
  126. package/tunnel.command-kd2yr4fx.js +129 -0
  127. package/{typeChecker-3xgrzc2v.js → typeChecker-px49mezc.js} +1 -1
  128. package/typecheck.proc.js +1 -1
  129. package/workflow.command-44252cqv.js +79 -0
  130. package/{workspace.command-8s050m0h.js → workspace.command-fqcztt5p.js} +77 -109
  131. package/abstractCompactor-mjh5ppsq.js +0 -101
  132. package/cloud.command-jshwdq22.js +0 -93
  133. package/context.command-ez8a0zyz.js +0 -80
  134. package/devTuiView-c08ccbat.js +0 -9
  135. package/getDirname-dr3jz1xg.js +0 -7
  136. package/guideline.command-xmqwx8zm.js +0 -359
  137. package/guidelines/agentRule/agentRule.generate.json +0 -31
  138. package/guidelines/componentRule/componentRule.generate.json +0 -31
  139. package/guidelines/conventions/conventions.generate.json +0 -25
  140. package/guidelines/cssRule/cssRule.generate.json +0 -31
  141. package/guidelines/docPageRule/docPageRule.generate.json +0 -31
  142. package/guidelines/docPageRule/docPageRule.instruction.md +0 -25
  143. package/guidelines/docSyncRule/docSyncRule.generate.json +0 -31
  144. package/guidelines/docSyncRule/docSyncRule.instruction.md +0 -25
  145. package/guidelines/enumConstant/enumConstant.generate.json +0 -31
  146. package/guidelines/enumConstant/enumConstant.instruction.md +0 -28
  147. package/guidelines/fieldRule/fieldRule.generate.json +0 -31
  148. package/guidelines/framework/framework.generate.json +0 -32
  149. package/guidelines/mcpRule/mcpRule.generate.json +0 -35
  150. package/guidelines/modelConstant/modelConstant.generate.json +0 -32
  151. package/guidelines/modelDictionary/modelDictionary.generate.json +0 -32
  152. package/guidelines/modelDocument/modelDocument.generate.json +0 -31
  153. package/guidelines/modelService/modelService.generate.json +0 -31
  154. package/guidelines/modelSignal/modelSignal.generate.json +0 -31
  155. package/guidelines/modelStore/modelStore.generate.json +0 -31
  156. package/guidelines/modelTemplate/modelTemplate.generate.json +0 -31
  157. package/guidelines/modelUnit/modelUnit.generate.json +0 -31
  158. package/guidelines/modelUtil/modelUtil.generate.json +0 -31
  159. package/guidelines/modelView/modelView.generate.json +0 -31
  160. package/guidelines/modelZone/modelZone.generate.json +0 -31
  161. package/guidelines/moduleCodegen/moduleCodegen.generate.json +0 -31
  162. package/guidelines/moduleCodegen/moduleCodegen.instruction.md +0 -28
  163. package/guidelines/moduleOverview/moduleOverview.generate.json +0 -31
  164. package/guidelines/queryRule/queryRule.generate.json +0 -31
  165. package/guidelines/recipeRule/recipeRule.generate.json +0 -31
  166. package/guidelines/runtimeRule/runtimeRule.generate.json +0 -25
  167. package/guidelines/scalarConstant/scalarConstant.generate.json +0 -32
  168. package/guidelines/scalarDictionary/scalarDictionary.generate.json +0 -32
  169. package/guidelines/scalarModule/scalarModule.generate.json +0 -31
  170. package/guidelines/sharedUiUsage/sharedUiUsage.generate.json +0 -31
  171. package/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +0 -25
  172. package/guidelines/ssrRule/ssrRule.generate.json +0 -31
  173. package/guidelines/transportRule/transportRule.generate.json +0 -31
  174. package/guidelines/utilUiUsage/utilUiUsage.generate.json +0 -31
  175. package/guidelines/utilUiUsage/utilUiUsage.instruction.md +0 -25
  176. package/guidelines/workspaceOnboarding/workspaceOnboarding.generate.json +0 -24
  177. package/guidelines/workspaceRecipes/workspaceRecipes.generate.json +0 -33
  178. package/index-2hq52jq3.js +0 -465
  179. package/index-6wwzs1bc.js +0 -7
  180. package/index-8pm30m73.js +0 -841
  181. package/index-kn1h7p1x.js +0 -560
  182. package/index-meh558jy.js +0 -65
  183. package/index-rwg2aa4f.js +0 -229
  184. package/templates/__scalar/__model__/__model__.abstract.md +0 -28
  185. package/templates/module/__model__.abstract.md +0 -28
  186. package/templates/service/__model__.abstract.md +0 -28
  187. package/workflow.command-nwpcdc8p.js +0 -107
@@ -1,7 +1,8 @@
1
1
  // @bun
2
2
  import {
3
- FileSys
4
- } from "./index-q0y2jq9j.js";
3
+ getDirname2,
4
+ FileSys2
5
+ } from "./index-5b6tavv3.js";
5
6
  import {
6
7
  Executor,
7
8
  WorkspaceExecutor,
@@ -9,10 +10,10 @@ import {
9
10
  LibExecutor,
10
11
  PkgExecutor,
11
12
  ModuleExecutor
12
- } from "./index-2tv3fdx4.js";
13
- import {
14
- getDirname2
15
- } from "./index-6wwzs1bc.js";
13
+ } from "./index-9d9bgcx4.js";
14
+
15
+ // pkgs/@akanjs/devkit/commandDecorators/camelToKebabCase.ts
16
+ var camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
16
17
 
17
18
  // pkgs/@akanjs/devkit/commandDecorators/targetMeta.ts
18
19
  var COMMAND_META = Symbol("akan.command.meta");
@@ -22,7 +23,6 @@ var getTargetMetas = (command) => {
22
23
  throw new Error(`TargetMeta is not defined for ${command.name}`);
23
24
  return [...targetMetaMap.values()];
24
25
  };
25
- var camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
26
26
  var getTargetCommandNames = (targetMeta) => {
27
27
  const kebabKey = camelToKebabCase(targetMeta.key);
28
28
  if (targetMeta.targetOption.short !== true)
@@ -59,30 +59,6 @@ var Pkg = createInternalArgToken("Pkg");
59
59
  var Module = createInternalArgToken("Module");
60
60
  var Workspace = createInternalArgToken("Workspace");
61
61
 
62
- // pkgs/@akanjs/devkit/commandDecorators/command.ts
63
- import path2 from "path";
64
- import { Logger } from "akanjs/common";
65
- import chalk2 from "chalk";
66
- import { program } from "commander";
67
-
68
- // pkgs/@akanjs/devkit/appSelectionMemory.ts
69
- import path from "path";
70
- class AppSelectionMemory {
71
- static pathIn(workspaceRoot) {
72
- return path.join(workspaceRoot, "local", ".akan", "lastStart.json");
73
- }
74
- static async read(workspaceRoot) {
75
- const stored = await Bun.file(AppSelectionMemory.pathIn(workspaceRoot)).json().catch(() => null);
76
- const apps = stored?.apps;
77
- return Array.isArray(apps) ? apps.filter((name) => typeof name === "string") : [];
78
- }
79
- static async write(workspaceRoot, apps) {
80
- await FileSys.writeJson(AppSelectionMemory.pathIn(workspaceRoot), { apps }).catch(() => {
81
- return;
82
- });
83
- }
84
- }
85
-
86
62
  // pkgs/@akanjs/devkit/commandDecorators/dependencyBuilder.ts
87
63
  var capitalize = (value) => value.slice(0, 1).toUpperCase() + value.slice(1);
88
64
  var createDependencyKey = (refName, kind) => `${refName}${capitalize(kind)}`;
@@ -160,20 +136,38 @@ var script = (refName, deps = []) => {
160
136
  return ScriptBase;
161
137
  };
162
138
 
139
+ // pkgs/@akanjs/devkit/commandDecorators/command.ts
140
+ import path2 from "path";
141
+ import { Logger } from "akanjs/common";
142
+ import chalk2 from "chalk";
143
+ import { program } from "commander";
144
+
145
+ // pkgs/@akanjs/devkit/appSelectionMemory.ts
146
+ import path from "path";
147
+ class AppSelectionMemory {
148
+ static pathIn(workspaceRoot) {
149
+ return path.join(workspaceRoot, "local", ".akan", "lastStart.json");
150
+ }
151
+ static async read(workspaceRoot) {
152
+ const stored = await Bun.file(AppSelectionMemory.pathIn(workspaceRoot)).json().catch(() => null);
153
+ const apps = stored?.apps;
154
+ return Array.isArray(apps) ? apps.filter((name) => typeof name === "string") : [];
155
+ }
156
+ static async write(workspaceRoot, apps) {
157
+ await FileSys2.writeJson(AppSelectionMemory.pathIn(workspaceRoot), { apps }).catch(() => {
158
+ return;
159
+ });
160
+ }
161
+ }
162
+
163
163
  // pkgs/@akanjs/devkit/commandDecorators/helpFormatter.ts
164
164
  import chalk from "chalk";
165
- var camelToKebabCase2 = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
166
165
  var formatChoice = (choice) => typeof choice === "object" ? choice.label : choice.toString();
167
166
  var groupCommands = (commands) => {
168
167
  const groups = new Map;
169
168
  for (const command of commands) {
170
- const className = command.name.replace("Command", "");
171
- const groupName = className;
172
- if (!groups.has(groupName)) {
173
- groups.set(groupName, { name: groupName, commands: [] });
174
- }
175
- const targetMetas = getTargetMetas(command);
176
- for (const targetMeta of targetMetas) {
169
+ const group = groups.getOrInsert(command.name.replace("Command", ""), []);
170
+ for (const targetMeta of getTargetMetas(command)) {
177
171
  if (targetMeta.targetOption.devOnly)
178
172
  continue;
179
173
  const [allArgMetas] = getArgMetas(command, targetMeta.key);
@@ -182,119 +176,72 @@ var groupCommands = (commands) => {
182
176
  return "";
183
177
  if (arg.type === "Module")
184
178
  return "[sys:module]";
185
- if (arg.type === "Argument") {
179
+ if (arg.type === "Argument")
186
180
  return `[${arg.name}]`;
187
- }
188
181
  return `[${arg.type.toLowerCase()}]`;
189
182
  }).filter(Boolean);
190
- const group = groups.get(groupName);
191
- if (group) {
192
- group.commands.push({
193
- key: camelToKebabCase2(targetMeta.key),
194
- args,
195
- desc: targetMeta.targetOption.desc
196
- });
197
- }
183
+ group.push({ key: camelToKebabCase(targetMeta.key), args, desc: targetMeta.targetOption.desc });
198
184
  }
199
185
  }
200
186
  return groups;
201
187
  };
202
188
  var formatHelp = (commands, version) => {
203
- const groups = groupCommands(commands);
204
- const lines = [];
205
- lines.push("");
206
- lines.push(chalk.bold.cyan(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557"));
207
- lines.push(chalk.bold.cyan(" \u2551") + chalk.bold.white(" Akan.js Framework CLI ") + chalk.bold.cyan(" \u2551"));
208
- lines.push(chalk.bold.cyan(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"));
209
- lines.push("");
210
- lines.push(chalk.gray(` Version: ${version}`));
211
- lines.push("");
212
- lines.push(chalk.bold.yellow(" USAGE"));
213
- lines.push("");
214
- lines.push(chalk.gray(" $ ") + chalk.white("akan") + chalk.gray(" <command> [options]"));
215
- lines.push("");
216
- lines.push(chalk.bold.yellow(" COMMANDS"));
217
- lines.push("");
218
- for (const [groupName, group] of groups) {
219
- if (group.commands.length === 0)
189
+ const lines = [
190
+ "",
191
+ chalk.bold.cyan(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557"),
192
+ chalk.bold.cyan(" \u2551") + chalk.bold.white(" Akan.js Framework CLI ") + chalk.bold.cyan(" \u2551"),
193
+ chalk.bold.cyan(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"),
194
+ "",
195
+ chalk.gray(` Version: ${version}`),
196
+ "",
197
+ chalk.bold.yellow(" USAGE"),
198
+ "",
199
+ chalk.gray(" $ ") + chalk.white("akan") + chalk.gray(" <command> [options]"),
200
+ "",
201
+ chalk.bold.yellow(" COMMANDS"),
202
+ ""
203
+ ];
204
+ for (const [groupName, cmds] of groupCommands(commands)) {
205
+ if (cmds.length === 0)
220
206
  continue;
221
- lines.push(chalk.bold.magenta(` ${groupName}`));
222
- lines.push("");
223
- for (const cmd of group.commands) {
224
- const cmdName = chalk.green(cmd.key);
225
- const cmdArgs = cmd.args.length > 0 ? chalk.gray(` ${cmd.args.join(" ")}`) : "";
226
- if (cmd.desc) {
227
- const maxLineLength = 70;
228
- const cmdPrefix = ` ${cmdName}${cmdArgs}`;
229
- const indent = " ";
230
- if (cmdPrefix.length + cmd.desc.length + 3 < maxLineLength) {
231
- lines.push(`${cmdPrefix} ${chalk.gray(cmd.desc)}`);
232
- } else {
233
- lines.push(cmdPrefix);
234
- lines.push(`${indent}${chalk.gray(cmd.desc)}`);
235
- }
236
- } else {
237
- lines.push(` ${cmdName}${cmdArgs}`);
238
- }
207
+ lines.push(chalk.bold.magenta(` ${groupName}`), "");
208
+ for (const cmd of cmds) {
209
+ const cmdPrefix = ` ${chalk.green(cmd.key)}${cmd.args.length > 0 ? chalk.gray(` ${cmd.args.join(" ")}`) : ""}`;
210
+ if (!cmd.desc)
211
+ lines.push(cmdPrefix);
212
+ else if (cmdPrefix.length + cmd.desc.length + 3 < 70)
213
+ lines.push(`${cmdPrefix} ${chalk.gray(cmd.desc)}`);
214
+ else
215
+ lines.push(cmdPrefix, ` ${chalk.gray(cmd.desc)}`);
239
216
  }
240
217
  lines.push("");
241
218
  }
242
- lines.push(chalk.bold.yellow(" OPTIONS"));
243
- lines.push("");
244
- lines.push(` ${chalk.green("-v, --verbose")} ${chalk.gray("Enable verbose output")}`);
245
- lines.push(` ${chalk.green("-h, --help")} ${chalk.gray("Display this help message")}`);
246
- lines.push(` ${chalk.green("-V, --version")} ${chalk.gray("Output version number")}`);
247
- lines.push("");
248
- lines.push(chalk.bold.yellow(" EXAMPLES"));
249
- lines.push("");
250
- lines.push(chalk.gray(" # Create a new workspace"));
251
- lines.push(chalk.white(" $ akan create-workspace myproject"));
252
- lines.push("");
253
- lines.push(chalk.gray(" # Start development server"));
254
- lines.push(chalk.white(" $ akan start myapp"));
255
- lines.push("");
256
- lines.push(chalk.gray(" # Create a new module"));
257
- lines.push(chalk.white(" $ akan create-module userProfile"));
258
- lines.push("");
259
- lines.push(chalk.gray(" Documentation: ") + chalk.cyan("https://akanjs.com/docs"));
260
- lines.push(chalk.gray(" Report issues: ") + chalk.cyan("https://github.com/akan-team/akanjs/issues"));
261
- lines.push("");
219
+ lines.push(chalk.bold.yellow(" OPTIONS"), "", ` ${chalk.green("-v, --verbose")} ${chalk.gray("Enable verbose output")}`, ` ${chalk.green("-h, --help")} ${chalk.gray("Display this help message")}`, ` ${chalk.green("-V, --version")} ${chalk.gray("Output version number")}`, "", chalk.bold.yellow(" EXAMPLES"), "", chalk.gray(" # Create a new workspace"), chalk.white(" $ akan create-workspace myproject"), "", chalk.gray(" # Start development server"), chalk.white(" $ akan start myapp"), "", chalk.gray(" # Create a new module"), chalk.white(" $ akan create-module userProfile"), "", chalk.gray(" Documentation: ") + chalk.cyan("https://akanjs.com/docs"), chalk.gray(" Report issues: ") + chalk.cyan("https://github.com/akan-team/akanjs/issues"), "");
262
220
  return lines.join(`
263
221
  `);
264
222
  };
265
223
  var formatCommandHelp = (command, key) => {
266
- const [allArgMetas, argMetas] = getArgMetas(command, key);
267
- const kebabKey = camelToKebabCase2(key);
268
- const lines = [];
269
- const targetMetas = getTargetMetas(command);
270
- const targetMeta = targetMetas.find((t) => t.key === key);
271
- const commandDesc = targetMeta?.targetOption.desc;
272
- lines.push("");
273
- lines.push(chalk.bold.cyan(` Command: ${kebabKey}`));
274
- if (commandDesc) {
275
- lines.push(chalk.gray(` ${commandDesc}`));
276
- }
277
- lines.push("");
278
- const args = allArgMetas.filter((arg) => arg.type !== "Option").map((arg) => {
224
+ const [allArgMetas, optionArgs] = getArgMetas(command, key);
225
+ const kebabKey = camelToKebabCase(key);
226
+ const commandDesc = getTargetMetas(command).find((t) => t.key === key)?.targetOption.desc;
227
+ const nonOptionArgs = allArgMetas.filter((arg) => arg.type !== "Option");
228
+ const args = nonOptionArgs.map((arg) => {
279
229
  if (arg.type === "Workspace")
280
230
  return "";
281
231
  if (arg.type === "Module")
282
232
  return "[sys:module]";
283
233
  if (arg.type === "Apps")
284
234
  return "[apps...]";
285
- if (arg.type === "Argument") {
286
- return `[${camelToKebabCase2(arg.name)}]`;
287
- }
235
+ if (arg.type === "Argument")
236
+ return `[${camelToKebabCase(arg.name)}]`;
288
237
  return `[${arg.type.toLowerCase()}]`;
289
238
  }).filter(Boolean).join(" ");
290
- lines.push(chalk.bold.yellow(" USAGE"));
291
- lines.push("");
292
- lines.push(chalk.gray(" $ ") + chalk.white(`akan ${kebabKey}`) + (args ? chalk.gray(` ${args}`) : ""));
293
- lines.push("");
294
- const nonOptionArgs = allArgMetas.filter((arg) => arg.type !== "Option");
239
+ const lines = ["", chalk.bold.cyan(` Command: ${kebabKey}`)];
240
+ if (commandDesc)
241
+ lines.push(chalk.gray(` ${commandDesc}`));
242
+ lines.push("", chalk.bold.yellow(" USAGE"), "", chalk.gray(" $ ") + chalk.white(`akan ${kebabKey}`) + (args ? chalk.gray(` ${args}`) : ""), "");
295
243
  if (nonOptionArgs.length > 0) {
296
- lines.push(chalk.bold.yellow(" ARGUMENTS"));
297
- lines.push("");
244
+ lines.push(chalk.bold.yellow(" ARGUMENTS"), "");
298
245
  for (const arg of nonOptionArgs) {
299
246
  if (arg.type === "Workspace")
300
247
  continue;
@@ -302,7 +249,7 @@ var formatCommandHelp = (command, key) => {
302
249
  let argDesc;
303
250
  let example = "";
304
251
  if (arg.type === "Argument") {
305
- argName = camelToKebabCase2(arg.name);
252
+ argName = camelToKebabCase(arg.name);
306
253
  argDesc = arg.argsOption.desc ?? "";
307
254
  example = arg.argsOption.example ? chalk.gray(` (e.g., ${String(arg.argsOption.example)})`) : "";
308
255
  } else if (arg.type === "Module") {
@@ -319,15 +266,14 @@ var formatCommandHelp = (command, key) => {
319
266
  }
320
267
  lines.push("");
321
268
  }
322
- const optionArgs = argMetas.filter((a) => a.type === "Option");
323
269
  if (optionArgs.length > 0) {
324
- lines.push(chalk.bold.yellow(" OPTIONS"));
325
- lines.push("");
270
+ lines.push(chalk.bold.yellow(" OPTIONS"), "");
326
271
  for (const arg of optionArgs) {
327
272
  const opt = arg.argsOption;
328
273
  const flag = opt.flag ? `-${opt.flag}, ` : "";
329
- const kebabName = camelToKebabCase2(arg.name);
330
- const optName = `${flag}--${kebabName}`;
274
+ const kebabName = camelToKebabCase(arg.name);
275
+ const negation = opt.type === "boolean" && opt.default === true ? `, --no-${kebabName}` : "";
276
+ const optName = `${flag}--${kebabName}${negation}`;
331
277
  const optDesc = opt.desc ?? "";
332
278
  const defaultVal = opt.default !== undefined ? chalk.gray(` [default: ${String(opt.default)}]`) : "";
333
279
  const choices = opt.enum ? chalk.gray(typeof opt.enum === "function" ? " ([dynamic choices])" : ` (${opt.enum.map(formatChoice).join(", ")})`) : "";
@@ -340,7 +286,6 @@ var formatCommandHelp = (command, key) => {
340
286
  };
341
287
 
342
288
  // pkgs/@akanjs/devkit/commandDecorators/command.ts
343
- var camelToKebabCase3 = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
344
289
  var loggedCliErrorObjects = new WeakSet;
345
290
  var loggedCliErrorMessages = new Set;
346
291
  var formatCliError = (error) => {
@@ -381,13 +326,15 @@ var handleOption = (programCommand, argMeta) => {
381
326
  enum: enumChoices,
382
327
  ask
383
328
  } = argMeta.argsOption;
384
- const kebabName = camelToKebabCase3(argMeta.name);
329
+ const kebabName = camelToKebabCase(argMeta.name);
385
330
  const choices = enumChoices && typeof enumChoices !== "function" ? normalizeEnumChoices(enumChoices) : null;
386
331
  programCommand.option(`-${flag}, --${kebabName}${type === "boolean" ? " [boolean]" : ` <${kebabName}>`}`, `${desc}${ask ? ` (${ask})` : ""}${example ? ` (example: ${example})` : ""}${choices ? ` (choices: ${choices.map((choice) => choice.name).join(", ")})` : ""}`);
332
+ if (type === "boolean" && argMeta.argsOption.default === true)
333
+ programCommand.option(`--no-${kebabName}`, `turn off --${kebabName}`);
387
334
  return programCommand;
388
335
  };
389
336
  var handleArgument = (programCommand, argMeta) => {
390
- const kebabName = camelToKebabCase3(argMeta.name);
337
+ const kebabName = camelToKebabCase(argMeta.name);
391
338
  programCommand.argument(`[${kebabName}]`, `${argMeta.argsOption.desc}${argMeta.argsOption.example ? ` (example: ${argMeta.argsOption.example})` : ""}`);
392
339
  return programCommand;
393
340
  };
@@ -412,21 +359,14 @@ var assertEnumChoice = (argMeta, value) => {
412
359
  const choices = normalizeEnumChoices(enumChoices);
413
360
  if (choices.some((choice) => String(choice.value) === String(value)))
414
361
  return;
415
- const label = argMeta.type === "Option" ? `option '--${camelToKebabCase3(argMeta.name)}'` : `argument '${argMeta.name}'`;
362
+ const label = argMeta.type === "Option" ? `option '--${camelToKebabCase(argMeta.name)}'` : `argument '${argMeta.name}'`;
416
363
  throw new Error(`${label} argument '${String(value)}' is invalid. Allowed choices are ${choices.map((choice) => choice.name).join(", ")}.`);
417
364
  };
418
- var resolveEnumChoices = async (argMeta, context) => {
419
- const enumChoices = argMeta.argsOption.enum;
420
- if (!enumChoices)
421
- return null;
422
- if (typeof enumChoices === "function")
423
- return await enumChoices(context);
424
- return enumChoices;
425
- };
365
+ var inputMessageOf = ({ name, argsOption: { desc, example, ask } }) => ask ? `${ask}: ` : desc ? `${desc}: ` : `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
426
366
  var getOptionValue = async (argMeta, opt, context) => {
427
367
  const {
428
368
  name,
429
- argsOption: { enum: enumChoices, default: defaultValue, type, desc, nullable, example, ask }
369
+ argsOption: { enum: enumChoices, default: defaultValue, type, desc, nullable, ask }
430
370
  } = argMeta;
431
371
  if (opt[argMeta.name] !== undefined) {
432
372
  assertEnumChoice(argMeta, opt[argMeta.name]);
@@ -434,29 +374,20 @@ var getOptionValue = async (argMeta, opt, context) => {
434
374
  } else if (defaultValue !== undefined)
435
375
  return defaultValue;
436
376
  if (enumChoices) {
437
- const choices = normalizeEnumChoices(await resolveEnumChoices(argMeta, context) ?? []);
377
+ const choices = normalizeEnumChoices((typeof enumChoices === "function" ? await enumChoices(context) : enumChoices) ?? []);
438
378
  if (choices.length === 1)
439
379
  return choices[0]?.value;
440
- const choice = await select({ message: ask ?? desc ?? `Select the ${name} value`, choices });
441
- return choice;
380
+ return await select({ message: ask ?? desc ?? `Select the ${name} value`, choices });
442
381
  } else if (nullable)
443
382
  return null;
444
383
  else if (type === "boolean") {
445
384
  const message = ask ?? desc ?? `Do you want to set ${name}? ${desc ? ` (${desc})` : ""}: `;
446
385
  return await confirm({ message });
447
- } else {
448
- const message = ask ? `${ask}: ` : desc ? `${desc}: ` : `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
449
- if (argMeta.argsOption.nullable)
450
- return await input({ message });
451
- else
452
- return convertArgValue(await input({ message }), type ?? "string");
453
- }
386
+ } else
387
+ return convertArgValue(await input({ message: inputMessageOf(argMeta) }), type ?? "string");
454
388
  };
455
389
  var getArgumentValue = async (argMeta, value) => {
456
- const {
457
- name,
458
- argsOption: { default: defaultValue, type, desc, nullable, example, ask }
459
- } = argMeta;
390
+ const { default: defaultValue, type, nullable } = argMeta.argsOption;
460
391
  if (value !== undefined) {
461
392
  assertEnumChoice(argMeta, value);
462
393
  return convertArgValue(value, type ?? "string");
@@ -464,8 +395,7 @@ var getArgumentValue = async (argMeta, value) => {
464
395
  return defaultValue;
465
396
  else if (nullable)
466
397
  return null;
467
- const message = ask ? `${ask}: ` : desc ? `${desc}: ` : `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
468
- return convertArgValue(await input({ message }), type ?? "string");
398
+ return convertArgValue(await input({ message: inputMessageOf(argMeta) }), type ?? "string");
469
399
  };
470
400
  var assignCommandContext = (context, argMeta, value) => {
471
401
  if (value instanceof AppExecutor)
@@ -486,9 +416,9 @@ var assignCommandContext = (context, argMeta, value) => {
486
416
  var assertCurrentDirectoryIsWorkspaceRoot = async () => {
487
417
  const cwd = process.cwd();
488
418
  const [hasPackageJson, hasTsConfig, hasEnv] = await Promise.all([
489
- FileSys.fileExists(`${cwd}/package.json`),
490
- FileSys.fileExists(`${cwd}/tsconfig.json`),
491
- FileSys.fileExists(`${cwd}/.env`)
419
+ FileSys2.fileExists(`${cwd}/package.json`),
420
+ FileSys2.fileExists(`${cwd}/tsconfig.json`),
421
+ FileSys2.fileExists(`${cwd}/.env`)
492
422
  ]);
493
423
  if (hasPackageJson && hasTsConfig && hasEnv)
494
424
  return;
@@ -529,44 +459,28 @@ var getInternalArgumentValue = async (argMeta, value, workspace) => {
529
459
  return workspace;
530
460
  const sysType = argMeta.type.toLowerCase();
531
461
  const [appNames, libNames, pkgNames] = await workspace.getExecs();
532
- if (sysType === "sys") {
533
- if (value && appNames.includes(value))
534
- return AppExecutor.from(workspace, value);
535
- else if (value && libNames.includes(value))
536
- return LibExecutor.from(workspace, value);
537
- else {
538
- const sysName = await select({
539
- message: `Select the App or Lib name`,
540
- choices: [...appNames, ...libNames]
541
- });
542
- if (appNames.includes(sysName))
543
- return AppExecutor.from(workspace, sysName);
544
- else if (libNames.includes(sysName))
545
- return LibExecutor.from(workspace, sysName);
546
- else
547
- throw new Error(`Invalid system name: ${sysName}`);
548
- }
549
- } else if (sysType === "exec") {
550
- if (value && appNames.includes(value))
551
- return AppExecutor.from(workspace, value);
552
- else if (value && libNames.includes(value))
553
- return LibExecutor.from(workspace, value);
554
- else if (value && pkgNames.includes(value))
555
- return PkgExecutor.from(workspace, value);
556
- else {
557
- const execName = await select({
558
- message: `Select the App or Lib or Pkg name`,
559
- choices: [...appNames, ...libNames, ...pkgNames]
560
- });
561
- if (appNames.includes(execName))
562
- return AppExecutor.from(workspace, execName);
563
- else if (libNames.includes(execName))
564
- return LibExecutor.from(workspace, execName);
565
- else if (pkgNames.includes(execName))
566
- return PkgExecutor.from(workspace, execName);
567
- else
568
- throw new Error(`Invalid system name: ${execName}`);
569
- }
462
+ if (sysType === "sys" || sysType === "exec") {
463
+ const pkgChoices = sysType === "exec" ? pkgNames : [];
464
+ const execOf = (name) => {
465
+ if (appNames.includes(name))
466
+ return AppExecutor.from(workspace, name);
467
+ if (libNames.includes(name))
468
+ return LibExecutor.from(workspace, name);
469
+ if (pkgChoices.includes(name))
470
+ return PkgExecutor.from(workspace, name);
471
+ return null;
472
+ };
473
+ const found = value ? execOf(value) : null;
474
+ if (found)
475
+ return found;
476
+ const name = await select({
477
+ message: sysType === "exec" ? `Select the App or Lib or Pkg name` : `Select the App or Lib name`,
478
+ choices: [...appNames, ...libNames, ...pkgChoices]
479
+ });
480
+ const picked = execOf(name);
481
+ if (!picked)
482
+ throw new Error(`Invalid system name: ${name}`);
483
+ return picked;
570
484
  } else if (sysType === "app") {
571
485
  if (value && appNames.includes(value))
572
486
  return AppExecutor.from(workspace, value);
@@ -631,9 +545,9 @@ var runCommands = async (...commands) => {
631
545
  const packageJsonCandidates = [`${path2.dirname(Bun.main)}/package.json`, `${__dirname2}/../package.json`];
632
546
  let cliPackageJson = null;
633
547
  for (const packageJsonPath of packageJsonCandidates) {
634
- if (!await FileSys.fileExists(packageJsonPath))
548
+ if (!await FileSys2.fileExists(packageJsonPath))
635
549
  continue;
636
- const packageJson = await FileSys.readJson(packageJsonPath);
550
+ const packageJson = await FileSys2.readJson(packageJsonPath);
637
551
  if (packageJson.name === "@akanjs/cli" || packageJson.name === "@akanjs/devkit") {
638
552
  cliPackageJson = packageJson;
639
553
  break;
@@ -641,17 +555,14 @@ var runCommands = async (...commands) => {
641
555
  }
642
556
  process.env.AKAN_VERSION = cliPackageJson?.version ?? "0.0.1";
643
557
  const hasHelpFlag = process.argv.includes("--help") || process.argv.includes("-h");
644
- const hasCommand = process.argv.length > 2 && !process.argv[2]?.startsWith("-");
645
- if (hasHelpFlag || !hasCommand) {
646
- if (process.argv.length === 2 || process.argv.length === 3 && hasHelpFlag) {
647
- Logger.rawLog(formatHelp(commands, process.env.AKAN_VERSION));
648
- process.exit(0);
649
- }
558
+ if (process.argv.length === 2 || process.argv.length === 3 && hasHelpFlag) {
559
+ Logger.rawLog(formatHelp(commands, process.env.AKAN_VERSION));
560
+ process.exit(0);
650
561
  }
651
562
  program.version(process.env.AKAN_VERSION).description("Akan CLI").configureHelp({
652
563
  helpWidth: 100
653
564
  });
654
- const installedAkanPackageJson = await FileSys.fileExists("./node_modules/akanjs/package.json") ? await FileSys.readJson("./node_modules/akanjs/package.json") : null;
565
+ const installedAkanPackageJson = await FileSys2.fileExists("./node_modules/akanjs/package.json") ? await FileSys2.readJson("./node_modules/akanjs/package.json") : null;
655
566
  if (installedAkanPackageJson && installedAkanPackageJson.version !== process.env.AKAN_VERSION) {
656
567
  Logger.rawLog(chalk2.yellow(`
657
568
  Akan CLI version is mismatch with installed package. ${process.env.AKAN_VERSION} (global) vs ${installedAkanPackageJson.version} (akanjs)
@@ -729,10 +640,15 @@ It may cause unexpected behavior. Run \`akan update\` to update latest akanjs.`)
729
640
  }
730
641
  }
731
642
  }
732
- await program.parseAsync(process.argv);
643
+ await program.parseAsync(process.argv).catch((error) => {
644
+ printCliError(error);
645
+ process.exit(1);
646
+ });
733
647
  };
734
648
 
735
649
  // pkgs/@akanjs/devkit/commandDecorators/commandBuilder.ts
650
+ var argMetaOf = (type, name, primitive, argsOption, idx) => ({ name, argsOption: { ...argsOption, type: normalizePrimitiveArgType(primitive) }, key: "", idx, type });
651
+
736
652
  class TargetBuilder {
737
653
  targetOption;
738
654
  #args;
@@ -740,39 +656,17 @@ class TargetBuilder {
740
656
  this.targetOption = targetOption;
741
657
  this.#args = args;
742
658
  }
659
+ #add(...argMetas) {
660
+ return new TargetBuilder(this.targetOption, [...this.#args, ...argMetas]);
661
+ }
743
662
  arg(name, type, argsOption = {}) {
744
- return new TargetBuilder(this.targetOption, [
745
- ...this.#args,
746
- {
747
- name,
748
- argsOption: { ...argsOption, type: normalizePrimitiveArgType(type) },
749
- key: "",
750
- idx: this.#args.length,
751
- type: "Argument"
752
- }
753
- ]);
663
+ return this.#add(argMetaOf("Argument", name, type, argsOption, this.#args.length));
754
664
  }
755
665
  option(name, type, argsOption = {}) {
756
- return new TargetBuilder(this.targetOption, [
757
- ...this.#args,
758
- {
759
- name,
760
- argsOption: { ...argsOption, type: normalizePrimitiveArgType(type) },
761
- key: "",
762
- idx: this.#args.length,
763
- type: "Option"
764
- }
765
- ]);
666
+ return this.#add(argMetaOf("Option", name, type, argsOption, this.#args.length));
766
667
  }
767
668
  with(...tokens) {
768
- return new TargetBuilder(this.targetOption, [
769
- ...this.#args,
770
- ...tokens.map((token, offset) => ({
771
- key: "",
772
- idx: this.#args.length + offset,
773
- type: token.type
774
- }))
775
- ]);
669
+ return this.#add(...tokens.map((token, offset) => ({ key: "", idx: this.#args.length + offset, type: token.type })));
776
670
  }
777
671
  exec(handler) {
778
672
  return {
@@ -787,20 +681,8 @@ var createContext = () => ({
787
681
  public: createTarget("public"),
788
682
  cloud: createTarget("cloud"),
789
683
  dev: createTarget("dev"),
790
- arg: (name, type, argsOption) => ({
791
- name,
792
- argsOption: { ...argsOption ?? {}, type: normalizePrimitiveArgType(type) },
793
- key: "",
794
- idx: -1,
795
- type: "Argument"
796
- }),
797
- option: (name, type, argsOption) => ({
798
- name,
799
- argsOption: { ...argsOption ?? {}, type: normalizePrimitiveArgType(type) },
800
- key: "",
801
- idx: -1,
802
- type: "Option"
803
- })
684
+ arg: (name, type, argsOption) => argMetaOf("Argument", name, type, argsOption, -1),
685
+ option: (name, type, argsOption) => argMetaOf("Option", name, type, argsOption, -1)
804
686
  });
805
687
  var buildCommandMeta = (definitions) => {
806
688
  const commandMeta = new Map;