@akanjs/cli 3.0.0-beta.19 → 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 (95) hide show
  1. package/.build-stamp +1 -1
  2. package/{CodeAgent-6cm97kay.js → CodeAgent-awv258wb.js} +2 -2
  3. package/{CodeTui-za4jsm41.js → CodeTui-1nqh35ez.js} +20 -22
  4. package/TunnelShare-scf4e4pd.js +9 -0
  5. package/{agent.command-e0wpbbyg.js → agent.command-1s9ag7sb.js} +8 -9
  6. package/akanCode.js +4 -4
  7. package/{application.command-8wyxqc8q.js → application.command-49hwy6va.js} +25 -56
  8. package/{applicationBuildRunner-n9gzaxd0.js → applicationBuildRunner-ybyp97pv.js} +33 -59
  9. package/{applicationReleasePackager-vpggfqgq.js → applicationReleasePackager-esnrphw8.js} +40 -60
  10. package/buildBatch.proc.js +19 -24
  11. package/{capacitorApp-q3z0qht0.js → capacitorApp-1synz4en.js} +3 -4
  12. package/{cloud.command-4zwa5dsx.js → cloud.command-d7rqtzt9.js} +16 -26
  13. package/cloud.script-bkbpcr96.js +19 -0
  14. package/{code.command-468c9d7s.js → code.command-nn48xzej.js} +22 -37
  15. package/context.command-s3mcmvpa.js +48 -0
  16. package/context.runner-k99nb5pk.js +21 -0
  17. package/{dependencyScanner-0z2h2tks.js → dependencyScanner-ye2e6pdz.js} +2 -2
  18. package/{devTui-ffjsarqa.js → devTui-q7k7bakd.js} +5 -9
  19. package/fileSys-5ngz93ga.js +9 -0
  20. package/{guideline.command-vhw13pqr.js → guideline.command-sct4qnt5.js} +4 -5
  21. package/guidelines/conventions/conventions.instruction.md +5 -1
  22. package/guidelines/mcpRule/mcpRule.instruction.md +7 -5
  23. package/incrementalBuilder.proc.js +30 -48
  24. package/{index-s5rhm04y.js → index-0bq14vr1.js} +1 -1
  25. package/{index-10dkrrww.js → index-13ffe9wp.js} +4 -4
  26. package/{index-srmay5jw.js → index-22d57v4c.js} +84 -67
  27. package/{index-53176s7j.js → index-31yr441d.js} +10 -17
  28. package/index-3hx1z96c.js +87 -0
  29. package/{index-4m929vvn.js → index-3sq321ak.js} +10 -18
  30. package/{index-bhtmj233.js → index-3t7g9e4r.js} +41 -78
  31. package/{index-q0y2jq9j.js → index-5b6tavv3.js} +6 -3
  32. package/{index-47pj3aee.js → index-5e0n4hqx.js} +11 -12
  33. package/{index-7ep8qtvp.js → index-5pc1qrbv.js} +5 -8
  34. package/{index-esk82rvk.js → index-8mna0947.js} +34 -71
  35. package/{index-sq2dzkzm.js → index-8sf7wmdr.js} +6 -6
  36. package/{index-crmeqnmf.js → index-9d9bgcx4.js} +283 -722
  37. package/{index-bwf965h6.js → index-ahemdr5n.js} +6 -6
  38. package/{index-ab0c38ea.js → index-as7xmyz8.js} +20 -20
  39. package/{index-bc88j1ry.js → index-axzjaqve.js} +94 -142
  40. package/{index-3d9y066c.js → index-bjwxs904.js} +9 -8
  41. package/{index-667w0yah.js → index-c6eggbee.js} +2 -5
  42. package/{index-a1w6934z.js → index-ddxvdd1p.js} +169 -305
  43. package/{index-92zztqy1.js → index-dy0jx9ay.js} +2 -17
  44. package/{index-22xtgmhn.js → index-dzf3r49a.js} +1 -1
  45. package/{index-89hy31kf.js → index-fgq75haa.js} +172 -287
  46. package/{index-by5gpp8x.js → index-hj6w4ka1.js} +2 -1
  47. package/{index-hwkygn9s.js → index-khpfpcsd.js} +302 -33
  48. package/{index-vqx8bdxz.js → index-mxav6j3c.js} +78 -231
  49. package/{index-2446k7b4.js → index-myhc3c1j.js} +512 -588
  50. package/{index-3jrp517k.js → index-nv5976x3.js} +45 -128
  51. package/{index-zqgj2rt2.js → index-przybvy5.js} +69 -147
  52. package/{index-n3cv0tm4.js → index-smme4r47.js} +1 -1
  53. package/{index-qdgzsnhg.js → index-w2zdcw3k.js} +110 -231
  54. package/{index-14zrtgfa.js → index-wa5jbxj1.js} +6 -39
  55. package/{index-bftkz6cp.js → index-ww4z397j.js} +198 -555
  56. package/{index-kwaq3n9n.js → index-xqjwd384.js} +4 -7
  57. package/{index-txr7dj2g.js → index-xqpzbab5.js} +106 -240
  58. package/{index-e4v6vhxq.js → index-xsjh6nzh.js} +178 -165
  59. package/{index-18zybgkc.js → index-ygn77a5w.js} +47 -99
  60. package/{index-9d6nvkz2.js → index-ztp3e73t.js} +79 -35
  61. package/index.js +23 -24
  62. package/{library.command-cqr175dy.js → library.command-1gx04jgn.js} +4 -5
  63. package/{localRegistry.command-49z55qqz.js → localRegistry.command-zndxj1q6.js} +21 -42
  64. package/{module.command-9p8mm3b0.js → module.command-3waddk95.js} +6 -7
  65. package/{package.command-wxyz909t.js → package.command-zrc7br1y.js} +5 -6
  66. package/package.json +2 -2
  67. package/{page.command-gsrsfqqs.js → page.command-vpjgardh.js} +4 -5
  68. package/{primitive.command-ns1mptje.js → primitive.command-sz84tk4t.js} +9 -20
  69. package/{prompter-1f8d9pcc.js → prompter-ptaa3nk0.js} +2 -2
  70. package/{quality.command-e76k2q9k.js → quality.command-g869hafs.js} +129 -363
  71. package/{recipeScanner-fpagtgc1.js → recipeScanner-4b69ybe0.js} +1 -1
  72. package/{repair.command-pkrsm3cw.js → repair.command-chsnjvvv.js} +11 -35
  73. package/{scalar.command-0cpt3fc8.js → scalar.command-2v21newx.js} +5 -6
  74. package/skills/akan-code/SKILL.md +12 -4
  75. package/{subspace.command-fktpwp0g.js → subspace.command-ckcbwfp1.js} +39 -58
  76. package/templates/appSample/srvkit/{AuthGuard.ts → guards.ts} +3 -3
  77. package/templates/appSample/srvkit/{SessionInternalArg.ts → internalArgs.ts} +3 -3
  78. package/templates/client.ts +7 -30
  79. package/templates/lib/__lib/lib.dictionary.ts +0 -2
  80. package/templates/lib/__lib/lib.document.ts +0 -2
  81. package/templates/lib/sig.ts +8 -30
  82. package/templates/server.ts +0 -2
  83. package/{tunnel.command-d5jy9gk8.js → tunnel.command-kd2yr4fx.js} +5 -6
  84. package/{typeChecker-3xgrzc2v.js → typeChecker-px49mezc.js} +1 -1
  85. package/typecheck.proc.js +1 -1
  86. package/workflow.command-44252cqv.js +79 -0
  87. package/{workspace.command-gv84eh1p.js → workspace.command-fqcztt5p.js} +72 -107
  88. package/TunnelShare-2j6s511d.js +0 -9
  89. package/cloud.script-fwx3vb34.js +0 -20
  90. package/context.command-dsnw0jby.js +0 -80
  91. package/context.runner-rs4rj15d.js +0 -22
  92. package/devTuiView-1q1mdgrv.js +0 -9
  93. package/getDirname-dr3jz1xg.js +0 -7
  94. package/index-6wwzs1bc.js +0 -7
  95. package/workflow.command-6tkcysmx.js +0 -105
@@ -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-crmeqnmf.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)
@@ -154,7 +154,7 @@ class AppSelectionMemory {
154
154
  return Array.isArray(apps) ? apps.filter((name) => typeof name === "string") : [];
155
155
  }
156
156
  static async write(workspaceRoot, apps) {
157
- await FileSys.writeJson(AppSelectionMemory.pathIn(workspaceRoot), { apps }).catch(() => {
157
+ await FileSys2.writeJson(AppSelectionMemory.pathIn(workspaceRoot), { apps }).catch(() => {
158
158
  return;
159
159
  });
160
160
  }
@@ -162,18 +162,12 @@ class AppSelectionMemory {
162
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,14 +266,12 @@ 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);
274
+ const kebabName = camelToKebabCase(arg.name);
330
275
  const negation = opt.type === "boolean" && opt.default === true ? `, --no-${kebabName}` : "";
331
276
  const optName = `${flag}--${kebabName}${negation}`;
332
277
  const optDesc = opt.desc ?? "";
@@ -341,7 +286,6 @@ var formatCommandHelp = (command, key) => {
341
286
  };
342
287
 
343
288
  // pkgs/@akanjs/devkit/commandDecorators/command.ts
344
- var camelToKebabCase3 = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
345
289
  var loggedCliErrorObjects = new WeakSet;
346
290
  var loggedCliErrorMessages = new Set;
347
291
  var formatCliError = (error) => {
@@ -382,7 +326,7 @@ var handleOption = (programCommand, argMeta) => {
382
326
  enum: enumChoices,
383
327
  ask
384
328
  } = argMeta.argsOption;
385
- const kebabName = camelToKebabCase3(argMeta.name);
329
+ const kebabName = camelToKebabCase(argMeta.name);
386
330
  const choices = enumChoices && typeof enumChoices !== "function" ? normalizeEnumChoices(enumChoices) : null;
387
331
  programCommand.option(`-${flag}, --${kebabName}${type === "boolean" ? " [boolean]" : ` <${kebabName}>`}`, `${desc}${ask ? ` (${ask})` : ""}${example ? ` (example: ${example})` : ""}${choices ? ` (choices: ${choices.map((choice) => choice.name).join(", ")})` : ""}`);
388
332
  if (type === "boolean" && argMeta.argsOption.default === true)
@@ -390,7 +334,7 @@ var handleOption = (programCommand, argMeta) => {
390
334
  return programCommand;
391
335
  };
392
336
  var handleArgument = (programCommand, argMeta) => {
393
- const kebabName = camelToKebabCase3(argMeta.name);
337
+ const kebabName = camelToKebabCase(argMeta.name);
394
338
  programCommand.argument(`[${kebabName}]`, `${argMeta.argsOption.desc}${argMeta.argsOption.example ? ` (example: ${argMeta.argsOption.example})` : ""}`);
395
339
  return programCommand;
396
340
  };
@@ -415,21 +359,14 @@ var assertEnumChoice = (argMeta, value) => {
415
359
  const choices = normalizeEnumChoices(enumChoices);
416
360
  if (choices.some((choice) => String(choice.value) === String(value)))
417
361
  return;
418
- 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}'`;
419
363
  throw new Error(`${label} argument '${String(value)}' is invalid. Allowed choices are ${choices.map((choice) => choice.name).join(", ")}.`);
420
364
  };
421
- var resolveEnumChoices = async (argMeta, context) => {
422
- const enumChoices = argMeta.argsOption.enum;
423
- if (!enumChoices)
424
- return null;
425
- if (typeof enumChoices === "function")
426
- return await enumChoices(context);
427
- return enumChoices;
428
- };
365
+ var inputMessageOf = ({ name, argsOption: { desc, example, ask } }) => ask ? `${ask}: ` : desc ? `${desc}: ` : `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
429
366
  var getOptionValue = async (argMeta, opt, context) => {
430
367
  const {
431
368
  name,
432
- argsOption: { enum: enumChoices, default: defaultValue, type, desc, nullable, example, ask }
369
+ argsOption: { enum: enumChoices, default: defaultValue, type, desc, nullable, ask }
433
370
  } = argMeta;
434
371
  if (opt[argMeta.name] !== undefined) {
435
372
  assertEnumChoice(argMeta, opt[argMeta.name]);
@@ -437,29 +374,20 @@ var getOptionValue = async (argMeta, opt, context) => {
437
374
  } else if (defaultValue !== undefined)
438
375
  return defaultValue;
439
376
  if (enumChoices) {
440
- const choices = normalizeEnumChoices(await resolveEnumChoices(argMeta, context) ?? []);
377
+ const choices = normalizeEnumChoices((typeof enumChoices === "function" ? await enumChoices(context) : enumChoices) ?? []);
441
378
  if (choices.length === 1)
442
379
  return choices[0]?.value;
443
- const choice = await select({ message: ask ?? desc ?? `Select the ${name} value`, choices });
444
- return choice;
380
+ return await select({ message: ask ?? desc ?? `Select the ${name} value`, choices });
445
381
  } else if (nullable)
446
382
  return null;
447
383
  else if (type === "boolean") {
448
384
  const message = ask ?? desc ?? `Do you want to set ${name}? ${desc ? ` (${desc})` : ""}: `;
449
385
  return await confirm({ message });
450
- } else {
451
- const message = ask ? `${ask}: ` : desc ? `${desc}: ` : `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
452
- if (argMeta.argsOption.nullable)
453
- return await input({ message });
454
- else
455
- return convertArgValue(await input({ message }), type ?? "string");
456
- }
386
+ } else
387
+ return convertArgValue(await input({ message: inputMessageOf(argMeta) }), type ?? "string");
457
388
  };
458
389
  var getArgumentValue = async (argMeta, value) => {
459
- const {
460
- name,
461
- argsOption: { default: defaultValue, type, desc, nullable, example, ask }
462
- } = argMeta;
390
+ const { default: defaultValue, type, nullable } = argMeta.argsOption;
463
391
  if (value !== undefined) {
464
392
  assertEnumChoice(argMeta, value);
465
393
  return convertArgValue(value, type ?? "string");
@@ -467,8 +395,7 @@ var getArgumentValue = async (argMeta, value) => {
467
395
  return defaultValue;
468
396
  else if (nullable)
469
397
  return null;
470
- const message = ask ? `${ask}: ` : desc ? `${desc}: ` : `Enter the ${name} value${example ? ` (example: ${example})` : ""}: `;
471
- return convertArgValue(await input({ message }), type ?? "string");
398
+ return convertArgValue(await input({ message: inputMessageOf(argMeta) }), type ?? "string");
472
399
  };
473
400
  var assignCommandContext = (context, argMeta, value) => {
474
401
  if (value instanceof AppExecutor)
@@ -489,9 +416,9 @@ var assignCommandContext = (context, argMeta, value) => {
489
416
  var assertCurrentDirectoryIsWorkspaceRoot = async () => {
490
417
  const cwd = process.cwd();
491
418
  const [hasPackageJson, hasTsConfig, hasEnv] = await Promise.all([
492
- FileSys.fileExists(`${cwd}/package.json`),
493
- FileSys.fileExists(`${cwd}/tsconfig.json`),
494
- FileSys.fileExists(`${cwd}/.env`)
419
+ FileSys2.fileExists(`${cwd}/package.json`),
420
+ FileSys2.fileExists(`${cwd}/tsconfig.json`),
421
+ FileSys2.fileExists(`${cwd}/.env`)
495
422
  ]);
496
423
  if (hasPackageJson && hasTsConfig && hasEnv)
497
424
  return;
@@ -532,44 +459,28 @@ var getInternalArgumentValue = async (argMeta, value, workspace) => {
532
459
  return workspace;
533
460
  const sysType = argMeta.type.toLowerCase();
534
461
  const [appNames, libNames, pkgNames] = await workspace.getExecs();
535
- if (sysType === "sys") {
536
- if (value && appNames.includes(value))
537
- return AppExecutor.from(workspace, value);
538
- else if (value && libNames.includes(value))
539
- return LibExecutor.from(workspace, value);
540
- else {
541
- const sysName = await select({
542
- message: `Select the App or Lib name`,
543
- choices: [...appNames, ...libNames]
544
- });
545
- if (appNames.includes(sysName))
546
- return AppExecutor.from(workspace, sysName);
547
- else if (libNames.includes(sysName))
548
- return LibExecutor.from(workspace, sysName);
549
- else
550
- throw new Error(`Invalid system name: ${sysName}`);
551
- }
552
- } else if (sysType === "exec") {
553
- if (value && appNames.includes(value))
554
- return AppExecutor.from(workspace, value);
555
- else if (value && libNames.includes(value))
556
- return LibExecutor.from(workspace, value);
557
- else if (value && pkgNames.includes(value))
558
- return PkgExecutor.from(workspace, value);
559
- else {
560
- const execName = await select({
561
- message: `Select the App or Lib or Pkg name`,
562
- choices: [...appNames, ...libNames, ...pkgNames]
563
- });
564
- if (appNames.includes(execName))
565
- return AppExecutor.from(workspace, execName);
566
- else if (libNames.includes(execName))
567
- return LibExecutor.from(workspace, execName);
568
- else if (pkgNames.includes(execName))
569
- return PkgExecutor.from(workspace, execName);
570
- else
571
- throw new Error(`Invalid system name: ${execName}`);
572
- }
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;
573
484
  } else if (sysType === "app") {
574
485
  if (value && appNames.includes(value))
575
486
  return AppExecutor.from(workspace, value);
@@ -634,9 +545,9 @@ var runCommands = async (...commands) => {
634
545
  const packageJsonCandidates = [`${path2.dirname(Bun.main)}/package.json`, `${__dirname2}/../package.json`];
635
546
  let cliPackageJson = null;
636
547
  for (const packageJsonPath of packageJsonCandidates) {
637
- if (!await FileSys.fileExists(packageJsonPath))
548
+ if (!await FileSys2.fileExists(packageJsonPath))
638
549
  continue;
639
- const packageJson = await FileSys.readJson(packageJsonPath);
550
+ const packageJson = await FileSys2.readJson(packageJsonPath);
640
551
  if (packageJson.name === "@akanjs/cli" || packageJson.name === "@akanjs/devkit") {
641
552
  cliPackageJson = packageJson;
642
553
  break;
@@ -644,17 +555,14 @@ var runCommands = async (...commands) => {
644
555
  }
645
556
  process.env.AKAN_VERSION = cliPackageJson?.version ?? "0.0.1";
646
557
  const hasHelpFlag = process.argv.includes("--help") || process.argv.includes("-h");
647
- const hasCommand = process.argv.length > 2 && !process.argv[2]?.startsWith("-");
648
- if (hasHelpFlag || !hasCommand) {
649
- if (process.argv.length === 2 || process.argv.length === 3 && hasHelpFlag) {
650
- Logger.rawLog(formatHelp(commands, process.env.AKAN_VERSION));
651
- process.exit(0);
652
- }
558
+ if (process.argv.length === 2 || process.argv.length === 3 && hasHelpFlag) {
559
+ Logger.rawLog(formatHelp(commands, process.env.AKAN_VERSION));
560
+ process.exit(0);
653
561
  }
654
562
  program.version(process.env.AKAN_VERSION).description("Akan CLI").configureHelp({
655
563
  helpWidth: 100
656
564
  });
657
- 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;
658
566
  if (installedAkanPackageJson && installedAkanPackageJson.version !== process.env.AKAN_VERSION) {
659
567
  Logger.rawLog(chalk2.yellow(`
660
568
  Akan CLI version is mismatch with installed package. ${process.env.AKAN_VERSION} (global) vs ${installedAkanPackageJson.version} (akanjs)
@@ -732,10 +640,15 @@ It may cause unexpected behavior. Run \`akan update\` to update latest akanjs.`)
732
640
  }
733
641
  }
734
642
  }
735
- await program.parseAsync(process.argv);
643
+ await program.parseAsync(process.argv).catch((error) => {
644
+ printCliError(error);
645
+ process.exit(1);
646
+ });
736
647
  };
737
648
 
738
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
+
739
652
  class TargetBuilder {
740
653
  targetOption;
741
654
  #args;
@@ -743,39 +656,17 @@ class TargetBuilder {
743
656
  this.targetOption = targetOption;
744
657
  this.#args = args;
745
658
  }
659
+ #add(...argMetas) {
660
+ return new TargetBuilder(this.targetOption, [...this.#args, ...argMetas]);
661
+ }
746
662
  arg(name, type, argsOption = {}) {
747
- return new TargetBuilder(this.targetOption, [
748
- ...this.#args,
749
- {
750
- name,
751
- argsOption: { ...argsOption, type: normalizePrimitiveArgType(type) },
752
- key: "",
753
- idx: this.#args.length,
754
- type: "Argument"
755
- }
756
- ]);
663
+ return this.#add(argMetaOf("Argument", name, type, argsOption, this.#args.length));
757
664
  }
758
665
  option(name, type, argsOption = {}) {
759
- return new TargetBuilder(this.targetOption, [
760
- ...this.#args,
761
- {
762
- name,
763
- argsOption: { ...argsOption, type: normalizePrimitiveArgType(type) },
764
- key: "",
765
- idx: this.#args.length,
766
- type: "Option"
767
- }
768
- ]);
666
+ return this.#add(argMetaOf("Option", name, type, argsOption, this.#args.length));
769
667
  }
770
668
  with(...tokens) {
771
- return new TargetBuilder(this.targetOption, [
772
- ...this.#args,
773
- ...tokens.map((token, offset) => ({
774
- key: "",
775
- idx: this.#args.length + offset,
776
- type: token.type
777
- }))
778
- ]);
669
+ return this.#add(...tokens.map((token, offset) => ({ key: "", idx: this.#args.length + offset, type: token.type })));
779
670
  }
780
671
  exec(handler) {
781
672
  return {
@@ -790,20 +681,8 @@ var createContext = () => ({
790
681
  public: createTarget("public"),
791
682
  cloud: createTarget("cloud"),
792
683
  dev: createTarget("dev"),
793
- arg: (name, type, argsOption) => ({
794
- name,
795
- argsOption: { ...argsOption ?? {}, type: normalizePrimitiveArgType(type) },
796
- key: "",
797
- idx: -1,
798
- type: "Argument"
799
- }),
800
- option: (name, type, argsOption) => ({
801
- name,
802
- argsOption: { ...argsOption ?? {}, type: normalizePrimitiveArgType(type) },
803
- key: "",
804
- idx: -1,
805
- type: "Option"
806
- })
684
+ arg: (name, type, argsOption) => argMetaOf("Argument", name, type, argsOption, -1),
685
+ option: (name, type, argsOption) => argMetaOf("Option", name, type, argsOption, -1)
807
686
  });
808
687
  var buildCommandMeta = (definitions) => {
809
688
  const commandMeta = new Map;
@@ -53,7 +53,7 @@ class CodeTuiLines2 {
53
53
  if (used && used + size > width)
54
54
  push(true);
55
55
  if (size > width) {
56
- for (const chunk of CodeTuiLines2.#chunks(word, width)) {
56
+ for (const chunk of CodeTuiLines2.chunks(word, width)) {
57
57
  if (used)
58
58
  push(true);
59
59
  line.push({ ...style, text: chunk });
@@ -75,7 +75,7 @@ class CodeTuiLines2 {
75
75
  static #words(text) {
76
76
  return text.match(/\S+\s*|\s+/g) ?? [];
77
77
  }
78
- static #chunks(word, width) {
78
+ static chunks(word, width) {
79
79
  const chunks = [];
80
80
  let chunk = "";
81
81
  for (const char of word) {
@@ -220,7 +220,8 @@ class CodeTuiClipboard2 {
220
220
  return;
221
221
  }
222
222
  static async#darwin() {
223
- return CodeTuiClipboard2.fromAppleScript(await CodeTuiClipboard2.#text(["osascript", "-e", CodeTuiClipboard2.ask]));
223
+ const bytes = await CodeTuiClipboard2.#bytes(["osascript", "-e", CodeTuiClipboard2.ask]);
224
+ return CodeTuiClipboard2.fromAppleScript(bytes ? new TextDecoder().decode(bytes) : undefined);
224
225
  }
225
226
  static ask = "the clipboard as \xABclass PNGf\xBB";
226
227
  static fromAppleScript(out) {
@@ -238,10 +239,6 @@ class CodeTuiClipboard2 {
238
239
  return;
239
240
  }
240
241
  }
241
- static async#text(command) {
242
- const bytes = await CodeTuiClipboard2.#bytes(command);
243
- return bytes ? new TextDecoder().decode(bytes) : undefined;
244
- }
245
242
  }
246
243
 
247
244
  // pkgs/@akanjs/cli/code/CodeTuiCommands.ts
@@ -398,7 +395,7 @@ class CodeTuiEditor2 {
398
395
  let at = 0;
399
396
  for (const line of this.#text.split(`
400
397
  `)) {
401
- for (const text of CodeTuiEditor2.#wrap(line, room)) {
398
+ for (const text of line ? CodeTuiLines2.chunks(line, room) : [""]) {
402
399
  rows.push({ text, at });
403
400
  at += text.length;
404
401
  }
@@ -422,22 +419,6 @@ class CodeTuiEditor2 {
422
419
  }
423
420
  return at;
424
421
  }
425
- static #wrap(line, width) {
426
- if (!line.length)
427
- return [""];
428
- const rows = [];
429
- let row = "";
430
- for (const char of line) {
431
- if (row && CodeTuiLines2.width(row + char) > width) {
432
- rows.push(row);
433
- row = "";
434
- }
435
- row += char;
436
- }
437
- if (row)
438
- rows.push(row);
439
- return rows;
440
- }
441
422
  static #prev(text, at) {
442
423
  if (at <= 0)
443
424
  return 0;
@@ -609,21 +590,7 @@ class CodeTuiMarkdown2 {
609
590
  }
610
591
  if (line.trim() || !lines.length)
611
592
  lines.push(line.trimEnd());
612
- return lines.flatMap((entry) => CodeTuiLines2.width(entry) <= width ? [entry] : CodeTuiMarkdown2.#hardSplit(entry, width));
613
- }
614
- static #hardSplit(text, width) {
615
- const chunks = [];
616
- let chunk = "";
617
- for (const char of text) {
618
- if (CodeTuiLines2.width(chunk + char) > width) {
619
- chunks.push(chunk);
620
- chunk = "";
621
- }
622
- chunk += char;
623
- }
624
- if (chunk)
625
- chunks.push(chunk);
626
- return chunks;
593
+ return lines.flatMap((entry) => CodeTuiLines2.width(entry) <= width ? [entry] : CodeTuiLines2.chunks(entry, width));
627
594
  }
628
595
  static spans(text, base = {}) {
629
596
  return MarkdownSpans.of(text).flatMap((span) => {