@akanjs/cli 3.1.0-rc.2 → 3.1.0-rc.21

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 (103) hide show
  1. package/.build-stamp +1 -1
  2. package/{CodeAgent-q50k4s45.js → CodeAgent-gzfc5t52.js} +2 -2
  3. package/{CodeAgentRpcHost-p7h6n2hp.js → CodeAgentRpcHost-9g27hmer.js} +1 -1
  4. package/{CodeTui-62g35ztk.js → CodeTui-bpsjs8wz.js} +47 -4
  5. package/TunnelShare-tfrnftgr.js +14 -0
  6. package/{agent.command-adfd5299.js → agent.command-67ysh3n6.js} +5 -5
  7. package/akanCode.js +7 -5
  8. package/{application.command-hj3gv1rx.js → application.command-q0tqw5pc.js} +38 -11
  9. package/{applicationBuildRunner-by10r9gf.js → applicationBuildRunner-wsszr305.js} +16 -9
  10. package/buildBatch.proc.js +7 -7
  11. package/{cloud.command-k2fhaape.js → cloud.command-e7tkxyx6.js} +17 -16
  12. package/cloud.script-krzh3d7k.js +24 -0
  13. package/{code.command-kt5zgcc2.js → code.command-ttk8tje2.js} +25 -12
  14. package/commandManifest.json +1 -1
  15. package/{context.command-8fgn42jw.js → context.command-bdsk2z2r.js} +17 -16
  16. package/context.runner-bxzv0gm0.js +25 -0
  17. package/{dependencyScanner-06z2dmrr.js → dependencyScanner-3afj2vt1.js} +1 -1
  18. package/{guideline.command-3yxxr2mm.js → guideline.command-man90n70.js} +2 -2
  19. package/guidelines/agentRule/agentRule.instruction.md +25 -10
  20. package/guidelines/conventions/conventions.instruction.md +486 -1084
  21. package/guidelines/cssRule/cssRule.instruction.md +16 -1
  22. package/guidelines/fieldRule/fieldRule.instruction.md +74 -0
  23. package/guidelines/framework/framework.instruction.md +4 -7
  24. package/guidelines/mcpRule/mcpRule.instruction.md +16 -9
  25. package/guidelines/modelConstant/modelConstant.instruction.md +2 -1
  26. package/guidelines/modelStore/modelStore.instruction.md +16 -0
  27. package/guidelines/pageRule/pageRule.instruction.md +80 -0
  28. package/guidelines/queryRule/queryRule.instruction.md +47 -12
  29. package/guidelines/runtimeRule/runtimeRule.instruction.md +89 -2
  30. package/guidelines/ssrRule/ssrRule.instruction.md +13 -0
  31. package/guidelines/transportRule/transportRule.instruction.md +107 -8
  32. package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +4 -4
  33. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +70 -7
  34. package/incrementalBuilder.proc.js +4 -4
  35. package/{index-rhbabmja.js → index-033wne2j.js} +260 -259
  36. package/{index-xpdgxsj5.js → index-1r5a8bzx.js} +2216 -2216
  37. package/{index-jwqtchha.js → index-27y8t17p.js} +1 -1
  38. package/{index-wa5jbxj1.js → index-2mrn1mrg.js} +1 -0
  39. package/{index-t7nws9mx.js → index-2w8j2fnv.js} +661 -448
  40. package/{index-0909wckt.js → index-35m6bzm7.js} +238 -236
  41. package/{index-sqfdmb5b.js → index-4393nb4b.js} +4 -4
  42. package/{index-sby8fe1p.js → index-48edp6q4.js} +1 -1
  43. package/{index-g0vwzy9m.js → index-4v43h00g.js} +20 -21
  44. package/{index-azh29dc8.js → index-54wc2phm.js} +19 -14
  45. package/{index-k9rrten6.js → index-5nd1wtkv.js} +92 -94
  46. package/index-62md4dwy.js +260 -0
  47. package/{index-hnby7p9n.js → index-75n5q4ph.js} +7 -7
  48. package/{index-fjsv10hd.js → index-844q7f8z.js} +7 -7
  49. package/{index-tv8fjaba.js → index-8jehkey8.js} +4 -4
  50. package/{index-bea2gwc6.js → index-9mt4smfy.js} +2 -2
  51. package/{index-d2242ksy.js → index-at7bz0xq.js} +3 -0
  52. package/{index-3hx1z96c.js → index-bqbf654f.js} +1 -1
  53. package/{index-8zdwpxef.js → index-cae9m5jz.js} +119 -81
  54. package/{index-tz5evhdr.js → index-ebarbgba.js} +6 -6
  55. package/{index-2etqq75t.js → index-g6ax17x4.js} +1114 -1082
  56. package/{index-h85cxfkg.js → index-g9ks2k8c.js} +2 -2
  57. package/{index-nq045px5.js → index-h3r3nr9y.js} +356 -307
  58. package/{index-20cebtth.js → index-h6czey01.js} +79 -24
  59. package/{index-6726qr1m.js → index-jrmzcp66.js} +57 -58
  60. package/{index-q958tqqg.js → index-m9jj544v.js} +1 -1
  61. package/{index-8935h3n1.js → index-mdjc93e1.js} +1 -1
  62. package/{index-rk9sdys3.js → index-nv79n88g.js} +5 -5
  63. package/{index-kc8z134d.js → index-nx64dz92.js} +38 -15
  64. package/{index-z507nzhg.js → index-p2r64bpa.js} +4 -4
  65. package/{index-nq2ja5e0.js → index-pg1t468s.js} +3 -3
  66. package/{index-3reaaa1h.js → index-rc51f9ht.js} +29 -27
  67. package/{index-e9prnmyt.js → index-ta1dychm.js} +3 -3
  68. package/{index-2ahj896a.js → index-tvehn2sp.js} +1 -1
  69. package/{index-31ce9vhg.js → index-vkb9m4z7.js} +80 -38
  70. package/{index-58vvz603.js → index-xsd96yzw.js} +1 -1
  71. package/{index-pyxn1b53.js → index-zv5s8x58.js} +13 -13
  72. package/index.js +22 -22
  73. package/{library.command-8tw59xzj.js → library.command-6amzsrb8.js} +3 -3
  74. package/{localRegistry.command-tf3dmznd.js → localRegistry.command-yqc0nyhh.js} +15 -14
  75. package/{module.command-9vm8hffy.js → module.command-10x6jv6c.js} +5 -5
  76. package/{package.command-erbxe2tz.js → package.command-pwfvecjf.js} +4 -4
  77. package/package.json +21 -21
  78. package/{page.command-jpavcj0p.js → page.command-ahhgx9y1.js} +3 -3
  79. package/{pipeline.command-b8rzvjvv.js → pipeline.command-1ptr3e9y.js} +3 -3
  80. package/{primitive.command-sm32chzk.js → primitive.command-g5xwv6tj.js} +6 -6
  81. package/{projectTypecheck-jamtx95x.js → projectTypecheck-fx8x7cat.js} +1 -1
  82. package/{quality.command-pkd17n6y.js → quality.command-fw9ck061.js} +4 -4
  83. package/{repair.command-8y4mq6hs.js → repair.command-g8kecj96.js} +5 -5
  84. package/{scalar.command-q8khmyx5.js → scalar.command-fprap51w.js} +4 -4
  85. package/skills/akan-code/SKILL.md +4 -0
  86. package/skills/akan-store/SKILL.md +2 -1
  87. package/{subspace.command-51n0ykbx.js → subspace.command-sc0t527y.js} +11 -10
  88. package/templates/appSample/lib/task/Task.Util.tsx +7 -7
  89. package/templates/appSample/lib/task/Task.Zone.tsx +1 -1
  90. package/templates/appSample/ui/QuantityControl.tsx +2 -2
  91. package/templates/crudSinglePage/page.tsx +1 -1
  92. package/templates/lib/cnst.ts +0 -1
  93. package/templates/migration/__migrationId__.ts +23 -0
  94. package/templates/server.ts +8 -1
  95. package/templates/workspaceRoot/.gitignore.template +23 -52
  96. package/templates/workspaceRoot/biome.json.template +1 -1
  97. package/{tunnel.command-7820vtxq.js → tunnel.command-mqnsqbwf.js} +8 -7
  98. package/{workflow.command-n5sv4wqz.js → workflow.command-j0jgkr13.js} +10 -10
  99. package/{workspace.command-zdy60jh8.js → workspace.command-1r9hvvw0.js} +29 -28
  100. package/TunnelShare-f1egrktx.js +0 -13
  101. package/cloud.script-z8p5dz7e.js +0 -23
  102. package/context.runner-hnh0rg7m.js +0 -24
  103. package/index-n68jx79w.js +0 -120
@@ -5,15 +5,15 @@ import {
5
5
  CloudApi,
6
6
  CloudUpdates,
7
7
  PipelineSecrets
8
- } from "./index-6726qr1m.js";
8
+ } from "./index-jrmzcp66.js";
9
9
  import {
10
10
  WorkspaceExecutor,
11
11
  AppExecutor
12
- } from "./index-2etqq75t.js";
12
+ } from "./index-g6ax17x4.js";
13
13
  import {
14
14
  runner,
15
15
  assertPromptable
16
- } from "./index-31ce9vhg.js";
16
+ } from "./index-vkb9m4z7.js";
17
17
  import {
18
18
  SubspaceConfig
19
19
  } from "./index-4pf8g7ff.js";
@@ -21,6 +21,25 @@ import {
21
21
  openBrowser
22
22
  } from "./index-9dp031by.js";
23
23
 
24
+ // pkgs/@akanjs/cli/npmRegistry.ts
25
+ var defaultNpmRegistry = "https://registry.npmjs.org";
26
+ var getNpmRegistryUrl = (registryUrl = process.env.AKAN_NPM_REGISTRY ?? defaultNpmRegistry) => registryUrl.replace(/\/+$/, "");
27
+ async function getLatestPackageVersion(packageName, tag = "latest", registryUrl) {
28
+ const registry = getNpmRegistryUrl(registryUrl);
29
+ const url = `${registry}/${encodeURIComponent(packageName).replace(/^%40/, "@")}`;
30
+ const res = await fetch(url);
31
+ if (!res.ok)
32
+ throw new Error(`Failed to fetch ${packageName} metadata from ${registry}`);
33
+ const metadata = await res.json();
34
+ const version = metadata["dist-tags"]?.[tag];
35
+ if (!version)
36
+ throw new Error(`No npm dist-tag "${tag}" found for ${packageName}`);
37
+ return version;
38
+ }
39
+
40
+ // pkgs/@akanjs/cli/cloud/cloud.runner.ts
41
+ import path7 from "path";
42
+
24
43
  // pkgs/@akanjs/devkit/platformTest/PlatformTestRun.ts
25
44
  import path6 from "path";
26
45
  import chalk from "chalk";
@@ -208,11 +227,13 @@ class PlatformTestTarget {
208
227
  const install = await this.exec("bun install --frozen-lockfile", logPath, PlatformTestTarget.installIdleMs);
209
228
  if (install.exitCode === 0)
210
229
  return;
211
- const failedScripts = [...install.output.matchAll(/(?:pre|post)?install script from "([^"]+)" exited/g)].map((match) => match[1] ?? "");
212
- const tolerable = failedScripts.length > 0 && failedScripts.every((pkg) => this.tolerateScriptFailures.includes(pkg));
230
+ const failedPackages = [
231
+ ...install.output.matchAll(/(?:pre|post)?install script from "([^"]+)" exited|failed to link binaries for package: (@?[^@\s]+)@/g)
232
+ ].map((match) => match[1] ?? match[2] ?? "");
233
+ const tolerable = failedPackages.length > 0 && failedPackages.every((pkg) => this.tolerateScriptFailures.includes(pkg));
213
234
  if (!tolerable)
214
235
  throw new Error(`bun install failed \u2014 see ${logPath}`);
215
- envWarnings.push(`install script failed for ${failedScripts.join(", ")} \u2014 tolerated on ${this.platform}`);
236
+ envWarnings.push(`install failed for ${failedPackages.join(", ")} \u2014 tolerated on ${this.platform}`);
216
237
  const relink = await this.exec("bun install --frozen-lockfile --ignore-scripts", this.#logPath(context, "install-relink"), PlatformTestTarget.installIdleMs);
217
238
  if (relink.exitCode !== 0)
218
239
  throw new Error(`bun install --ignore-scripts failed \u2014 see ${logPath}`);
@@ -249,7 +270,7 @@ class LinuxDockerTarget extends PlatformTestTarget {
249
270
  }
250
271
  static dockerfile = [
251
272
  `FROM oven/bun:${Bun.version}-slim`,
252
- "RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates procps lsof && rm -rf /var/lib/apt/lists/*"
273
+ "RUN sed -i 's|http://|https://|g' /etc/apt/sources.list.d/debian.sources && apt-get update && apt-get install -y --no-install-recommends git ca-certificates procps lsof && rm -rf /var/lib/apt/lists/*"
253
274
  ].join(`
254
275
  `);
255
276
  get image() {
@@ -412,7 +433,7 @@ import path5 from "path";
412
433
  class WindowsSshTarget extends PlatformTestTarget {
413
434
  static utmctlPath = "/Applications/UTM.app/Contents/MacOS/utmctl";
414
435
  static defaultWorkRoot = "C:\\akan-test";
415
- static defaultTolerateScriptFailures = ["sharp", "puppeteer"];
436
+ static defaultTolerateScriptFailures = ["sharp", "puppeteer", "msgpackr"];
416
437
  static #runDirPattern = "^\\d{8}-\\d{6}$";
417
438
  static #keptRuns = 2;
418
439
  platform = "windows";
@@ -653,29 +674,10 @@ class PlatformTestRun {
653
674
  }
654
675
 
655
676
  // pkgs/@akanjs/cli/cloud/cloud.runner.ts
656
- import path7 from "path";
657
677
  import { confirm, input, select } from "@inquirer/prompts";
658
678
  import { Logger, sleep } from "akanjs/common";
659
679
  import chalk2 from "chalk";
660
680
  import * as QRcode from "qrcode";
661
-
662
- // pkgs/@akanjs/cli/npmRegistry.ts
663
- var defaultNpmRegistry = "https://registry.npmjs.org";
664
- var getNpmRegistryUrl = (registryUrl = process.env.AKAN_NPM_REGISTRY ?? defaultNpmRegistry) => registryUrl.replace(/\/+$/, "");
665
- async function getLatestPackageVersion(packageName, tag = "latest", registryUrl) {
666
- const registry = getNpmRegistryUrl(registryUrl);
667
- const url = `${registry}/${encodeURIComponent(packageName).replace(/^%40/, "@")}`;
668
- const res = await fetch(url);
669
- if (!res.ok)
670
- throw new Error(`Failed to fetch ${packageName} metadata from ${registry}`);
671
- const metadata = await res.json();
672
- const version = metadata["dist-tags"]?.[tag];
673
- if (!version)
674
- throw new Error(`No npm dist-tag "${tag}" found for ${packageName}`);
675
- return version;
676
- }
677
-
678
- // pkgs/@akanjs/cli/cloud/cloud.runner.ts
679
681
  var addRemoteEnvServerValue = "__addRemoteEnvServer";
680
682
  var removeRemoteEnvServerValue = "__removeRemoteEnvServer";
681
683
 
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-31ce9vhg.js";
5
+ } from "./index-vkb9m4z7.js";
6
6
  import {
7
7
  AGENT_BLOCK_START,
8
8
  AGENT_BLOCK_END,
@@ -13,14 +13,14 @@ import {
13
13
  CLAUDE_COMMENT_RULE,
14
14
  AppExecutor,
15
15
  LibExecutor
16
- } from "./index-2etqq75t.js";
16
+ } from "./index-g6ax17x4.js";
17
17
  import {
18
18
  collectRecipeSources2,
19
19
  scanRecipes2
20
20
  } from "./index-hj6w4ka1.js";
21
21
  import {
22
22
  AkanContextAnalyzer
23
- } from "./index-rk9sdys3.js";
23
+ } from "./index-nv79n88g.js";
24
24
  import {
25
25
  Prompter2
26
26
  } from "./index-zzvvc845.js";
@@ -87,7 +87,7 @@ class TypeScriptDependencyScanner2 {
87
87
  return {
88
88
  npmDeps: [...runtimeDeps].sort(),
89
89
  npmDevDeps: [...devDeps].sort(),
90
- missingDeps: missingDeps.sort()
90
+ missingDeps: missingDeps.sort((a, b) => a < b ? -1 : a > b ? 1 : 0)
91
91
  };
92
92
  }
93
93
  async#hasWorkspacePackage(dep) {
@@ -10,7 +10,7 @@ import {
10
10
  LibExecutor,
11
11
  PkgExecutor,
12
12
  ModuleExecutor
13
- } from "./index-2etqq75t.js";
13
+ } from "./index-g6ax17x4.js";
14
14
 
15
15
  // pkgs/@akanjs/devkit/commandDecorators/camelToKebabCase.ts
16
16
  var camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
@@ -59,6 +59,29 @@ var Exec = createInternalArgToken("Exec");
59
59
  var Pkg = createInternalArgToken("Pkg");
60
60
  var Module = createInternalArgToken("Module");
61
61
  var Workspace = createInternalArgToken("Workspace");
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 FileSys2.writeJson(AppSelectionMemory.pathIn(workspaceRoot), { apps }).catch(() => {
81
+ return;
82
+ });
83
+ }
84
+ }
62
85
 
63
86
  // pkgs/@akanjs/devkit/commandDecorators/dependencyBuilder.ts
64
87
  var capitalize = (value) => value.slice(0, 1).toUpperCase() + value.slice(1);
@@ -137,30 +160,6 @@ var script = (refName, deps = []) => {
137
160
  return ScriptBase;
138
161
  };
139
162
 
140
- // pkgs/@akanjs/devkit/commandDecorators/command.ts
141
- import path2 from "path";
142
- import { Logger } from "akanjs/common";
143
- import chalk2 from "chalk";
144
- import { program } from "commander";
145
-
146
- // pkgs/@akanjs/devkit/appSelectionMemory.ts
147
- import path from "path";
148
- class AppSelectionMemory {
149
- static pathIn(workspaceRoot) {
150
- return path.join(workspaceRoot, "local", ".akan", "lastStart.json");
151
- }
152
- static async read(workspaceRoot) {
153
- const stored = await Bun.file(AppSelectionMemory.pathIn(workspaceRoot)).json().catch(() => null);
154
- const apps = stored?.apps;
155
- return Array.isArray(apps) ? apps.filter((name) => typeof name === "string") : [];
156
- }
157
- static async write(workspaceRoot, apps) {
158
- await FileSys2.writeJson(AppSelectionMemory.pathIn(workspaceRoot), { apps }).catch(() => {
159
- return;
160
- });
161
- }
162
- }
163
-
164
163
  // pkgs/@akanjs/devkit/commandDecorators/exitCodeError.ts
165
164
  class ExitCodeError extends Error {
166
165
  exitCode;
@@ -290,8 +289,9 @@ var formatCommandHelp = (command, key) => {
290
289
  const optName = `${flag}--${kebabName}${negation}`;
291
290
  const optDesc = opt.desc ?? "";
292
291
  const defaultVal = opt.default !== undefined ? chalk.gray(` [default: ${String(opt.default)}]`) : "";
292
+ const repeatable = opt.multiple ? chalk.gray(" (repeatable)") : "";
293
293
  const choices = opt.enum ? chalk.gray(typeof opt.enum === "function" ? " ([dynamic choices])" : ` (${opt.enum.map(formatChoice).join(", ")})`) : "";
294
- lines.push(` ${chalk.green(optName)} ${chalk.gray(optDesc)}${defaultVal}${choices}`);
294
+ lines.push(` ${chalk.green(optName)} ${chalk.gray(optDesc)}${defaultVal}${choices}${repeatable}`);
295
295
  }
296
296
  lines.push("");
297
297
  }
@@ -302,6 +302,10 @@ var formatCommandHelp = (command, key) => {
302
302
  // pkgs/@akanjs/devkit/commandDecorators/command.ts
303
303
  var loggedCliErrorObjects = new WeakSet;
304
304
  var loggedCliErrorMessages = new Set;
305
+ var markCliErrorPrinted = (error) => {
306
+ if (typeof error === "object" && error !== null)
307
+ loggedCliErrorObjects.add(error);
308
+ };
305
309
  var formatCliError = (error) => {
306
310
  if (error instanceof Error)
307
311
  return error.message || error.name;
@@ -342,7 +346,12 @@ var handleOption = (programCommand, argMeta) => {
342
346
  } = argMeta.argsOption;
343
347
  const kebabName = camelToKebabCase(argMeta.name);
344
348
  const choices = enumChoices && typeof enumChoices !== "function" ? normalizeEnumChoices(enumChoices) : null;
345
- programCommand.option(`-${flag}, --${kebabName}${type === "boolean" ? " [boolean]" : ` <${kebabName}>`}`, `${desc}${ask ? ` (${ask})` : ""}${example ? ` (example: ${example})` : ""}${choices ? ` (choices: ${choices.map((choice) => choice.name).join(", ")})` : ""}`);
349
+ const flags = `-${flag}, --${kebabName}${type === "boolean" ? " [boolean]" : ` <${kebabName}>`}`;
350
+ const description = `${desc}${ask ? ` (${ask})` : ""}${example ? ` (example: ${example})` : ""}${choices ? ` (choices: ${choices.map((choice) => choice.name).join(", ")})` : ""}`;
351
+ if (argMeta.argsOption.multiple)
352
+ programCommand.option(flags, description, (value, previous = []) => [...previous, value]);
353
+ else
354
+ programCommand.option(flags, description);
346
355
  if (type === "boolean" && argMeta.argsOption.default === true)
347
356
  programCommand.option(`--no-${kebabName}`, `turn off --${kebabName}`);
348
357
  return programCommand;
@@ -360,6 +369,17 @@ var convertArgValue = (value, type) => {
360
369
  else
361
370
  return value === true || value === "true";
362
371
  };
372
+ var givenOptionsOf = (argMetas, opt) => {
373
+ const given = {};
374
+ for (const argMeta of argMetas) {
375
+ if (argMeta.type !== "Option" || opt[argMeta.name] === undefined)
376
+ continue;
377
+ const type = argMeta.argsOption.type ?? "string";
378
+ const value = opt[argMeta.name];
379
+ given[argMeta.name] = Array.isArray(value) ? value.map((each) => convertArgValue(each, type)) : convertArgValue(value, type);
380
+ }
381
+ return given;
382
+ };
363
383
  var normalizeEnumChoices = (enumChoices) => enumChoices.map((choice) => typeof choice === "object" ? { value: choice.value, name: choice.label } : { value: choice, name: choice.toString() });
364
384
  var prompts = async () => await import("@inquirer/prompts");
365
385
  var select = (config, context) => prompts().then((m) => m.select(config, context));
@@ -385,8 +405,14 @@ var inputMessageOf = ({ name, argsOption: { desc, example, ask } }) => ask ? `${
385
405
  var getOptionValue = async (argMeta, opt, context) => {
386
406
  const {
387
407
  name,
388
- argsOption: { enum: enumChoices, default: defaultValue, type, desc, nullable, ask }
408
+ argsOption: { enum: enumChoices, default: defaultValue, type, desc, nullable, ask, multiple }
389
409
  } = argMeta;
410
+ if (multiple) {
411
+ const values = opt[argMeta.name] ?? [];
412
+ for (const value of values)
413
+ assertEnumChoice(argMeta, value);
414
+ return values.map((value) => convertArgValue(value, type ?? "string"));
415
+ }
390
416
  if (opt[argMeta.name] !== undefined) {
391
417
  assertEnumChoice(argMeta, opt[argMeta.name]);
392
418
  return convertArgValue(opt[argMeta.name], type ?? "string");
@@ -441,17 +467,17 @@ var assignCommandContext = (context, argMeta, value) => {
441
467
  };
442
468
  var assertCurrentDirectoryIsWorkspaceRoot = async () => {
443
469
  const cwd = process.cwd();
444
- const [hasPackageJson, hasTsConfig, hasEnv] = await Promise.all([
470
+ const [hasPackageJson, hasTsConfig, ...hasMemberDirs] = await Promise.all([
445
471
  FileSys2.fileExists(`${cwd}/package.json`),
446
472
  FileSys2.fileExists(`${cwd}/tsconfig.json`),
447
- FileSys2.fileExists(`${cwd}/.env`)
473
+ ...["apps", "libs", "pkgs"].map((dir) => FileSys2.dirExists(`${cwd}/${dir}`))
448
474
  ]);
449
- if (hasPackageJson && hasTsConfig && hasEnv)
475
+ if (hasPackageJson && hasTsConfig && hasMemberDirs.some(Boolean))
450
476
  return;
451
477
  throw new Error([
452
478
  "Akan CLI commands must be run from the workspace root.",
453
479
  `Current directory: ${cwd}`,
454
- "Move to the directory that contains package.json, tsconfig.json, and .env, then run the command again."
480
+ "Move to the directory that contains package.json, tsconfig.json, and an apps/, libs/ or pkgs/ folder, then run the command again."
455
481
  ].join(`
456
482
  `));
457
483
  };
@@ -575,6 +601,7 @@ var getInternalArgumentValue = async (argMeta, value, workspace) => {
575
601
  };
576
602
  var runCommands = async (...commands) => {
577
603
  let failureExitCode = 1;
604
+ let reportFailure = async (_error) => {};
578
605
  process.on("unhandledRejection", (error) => {
579
606
  printCliError(error);
580
607
  process.exit(ExitCodeError.codeOf(error) ?? failureExitCode);
@@ -615,9 +642,19 @@ It may cause unexpected behavior. Run \`akan update\` to update latest akanjs.`)
615
642
  hidden: targetMeta.targetOption.devOnly
616
643
  });
617
644
  const targetFailureExitCode = targetMeta.targetOption.failureExitCode;
618
- if (targetFailureExitCode !== undefined)
619
- programCommand.exitOverride((error) => process.exit(error.exitCode === 0 ? 0 : targetFailureExitCode));
645
+ const usageExitCode = targetMeta.targetOption.usageExitCode ?? targetFailureExitCode;
646
+ const { onFailure } = targetMeta.targetOption;
620
647
  const [allArgMetas] = getArgMetas(command, targetMeta.key);
648
+ if (usageExitCode !== undefined || onFailure)
649
+ programCommand.exitOverride((error) => {
650
+ if (error.exitCode === 0)
651
+ process.exit(0);
652
+ const refused = new ExitCodeError(error.message.replace(/^error: /, ""), usageExitCode ?? error.exitCode);
653
+ markCliErrorPrinted(refused);
654
+ const given = givenOptionsOf(allArgMetas, programCommand.opts());
655
+ reportFailure = async (failure) => await onFailure?.(failure, { usage: true, given });
656
+ throw refused;
657
+ });
621
658
  for (const argMeta of allArgMetas) {
622
659
  if (argMeta.type === "Option")
623
660
  programCommand = handleOption(programCommand, argMeta);
@@ -644,6 +681,7 @@ It may cause unexpected behavior. Run \`akan update\` to update latest akanjs.`)
644
681
  Logger.rawLog();
645
682
  const cmdArgs = args.slice(0, args.length - 2);
646
683
  const opt = args[args.length - 2];
684
+ reportFailure = async (failure) => await onFailure?.(failure, { usage: false, given: givenOptionsOf(allArgMetas, opt) });
647
685
  const commandArgs = [];
648
686
  if (targetMeta.targetOption.runsOnWorkspaceRoot)
649
687
  await assertCurrentDirectoryIsWorkspaceRoot();
@@ -682,14 +720,18 @@ It may cause unexpected behavior. Run \`akan update\` to update latest akanjs.`)
682
720
  }
683
721
  }
684
722
  }
685
- await program.parseAsync(process.argv).catch((error) => {
723
+ await program.parseAsync(process.argv).catch(async (error) => {
686
724
  printCliError(error);
725
+ await reportFailure(error).catch(printCliError);
687
726
  process.exit(ExitCodeError.codeOf(error) ?? failureExitCode);
688
727
  });
689
728
  };
690
-
691
729
  // pkgs/@akanjs/devkit/commandDecorators/commandBuilder.ts
692
- var argMetaOf = (type, name, primitive, argsOption, idx) => ({ name, argsOption: { ...argsOption, type: normalizePrimitiveArgType(primitive) }, key: "", idx, type });
730
+ var argMetaOf = (type, name, primitive, argsOption, idx) => {
731
+ if (type === "Argument" && argsOption?.multiple)
732
+ throw new Error(`argument '${name}' cannot be multiple`);
733
+ return { name, argsOption: { ...argsOption, type: normalizePrimitiveArgType(primitive) }, key: "", idx, type };
734
+ };
693
735
 
694
736
  class TargetBuilder {
695
737
  targetOption;
@@ -760,4 +802,4 @@ function command(refName, depsOrBuilder, builder) {
760
802
  }
761
803
  return CommandBase;
762
804
  }
763
- export { getTargetMetas, getTargetCommandNames, App, Apps, Lib, Sys, SysOrOnlyApp, Exec, Pkg, Module, Workspace, CommandContainer, runner, script, ExitCodeError, assertPromptable, runCommands, command };
805
+ export { getTargetMetas, getTargetCommandNames, App, Apps, Lib, Sys, SysOrOnlyApp, Exec, Pkg, Module, Workspace, CommandContainer, runner, script, ExitCodeError, markCliErrorPrinted, assertPromptable, runCommands, command };
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  AppInfo
4
- } from "./index-2etqq75t.js";
4
+ } from "./index-g6ax17x4.js";
5
5
 
6
6
  // pkgs/@akanjs/devkit/slicePlanner.ts
7
7
  class SlicePlanner {
@@ -1,13 +1,13 @@
1
1
  // @bun
2
2
  import {
3
3
  AppExecutor
4
- } from "./index-2etqq75t.js";
4
+ } from "./index-g6ax17x4.js";
5
5
  import {
6
6
  jsonText,
7
7
  createWorkflowBaselineSummary,
8
8
  buildAkanModuleContextIndex,
9
9
  toolingRolloutGate
10
- } from "./index-rhbabmja.js";
10
+ } from "./index-033wne2j.js";
11
11
  import {
12
12
  buildResourceList,
13
13
  codexMcpConfigPath,
@@ -17,29 +17,29 @@ import {
17
17
  upsertCodexMcpServerBlock,
18
18
  renderDoctorText,
19
19
  AkanContextAnalyzer
20
- } from "./index-rk9sdys3.js";
20
+ } from "./index-nv79n88g.js";
21
21
  import {
22
22
  runner
23
- } from "./index-31ce9vhg.js";
23
+ } from "./index-vkb9m4z7.js";
24
24
  import {
25
25
  isPlaceholderAppId
26
- } from "./index-g0vwzy9m.js";
26
+ } from "./index-4v43h00g.js";
27
+ import {
28
+ getMobileTargets,
29
+ appIdsOf
30
+ } from "./index-m9jj544v.js";
27
31
  import {
28
32
  NativeApp
29
- } from "./index-0909wckt.js";
33
+ } from "./index-35m6bzm7.js";
30
34
  import {
31
35
  Prompter2
32
36
  } from "./index-zzvvc845.js";
33
37
  import {
34
38
  RepairRunner
35
- } from "./index-nq2ja5e0.js";
39
+ } from "./index-pg1t468s.js";
36
40
  import {
37
41
  WorkflowRunner
38
- } from "./index-hnby7p9n.js";
39
- import {
40
- getMobileTargets,
41
- appIdsOf
42
- } from "./index-q958tqqg.js";
42
+ } from "./index-75n5q4ph.js";
43
43
 
44
44
  // pkgs/@akanjs/devkit/akanMcpContract.ts
45
45
  import path from "path";
@@ -127,7 +127,7 @@ var inspectAkanContextInputSchema = {
127
127
  },
128
128
  required: ["question", "draft", "review", "request"]
129
129
  };
130
- var slugPart = (value) => typeof value === "string" ? value.trim().replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase() : "";
130
+ var slugPart = (value) => typeof value === "string" ? value.trim().replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-|-$/g, "").toLowerCase() : "";
131
131
  var optionalString = (args, key) => {
132
132
  const value = args[key];
133
133
  return typeof value === "string" && value ? value : undefined;
package/index.js CHANGED
@@ -4,35 +4,35 @@ import {
4
4
  getTargetMetas,
5
5
  getTargetCommandNames,
6
6
  runCommands
7
- } from "./index-31ce9vhg.js";
7
+ } from "./index-vkb9m4z7.js";
8
8
  import"./index-52w0fvh8.js";
9
- import"./index-2etqq75t.js";
9
+ import"./index-g6ax17x4.js";
10
10
 
11
11
  // pkgs/@akanjs/cli/commandManifest.ts
12
12
  import path from "path";
13
13
 
14
14
  // pkgs/@akanjs/cli/commandModules.ts
15
15
  var commandModules = {
16
- workspace: async () => (await import("./workspace.command-zdy60jh8.js")).WorkspaceCommand,
17
- agent: async () => (await import("./agent.command-adfd5299.js")).AgentCommand,
18
- code: async () => (await import("./code.command-kt5zgcc2.js")).CodeCommand,
19
- application: async () => (await import("./application.command-hj3gv1rx.js")).ApplicationCommand,
20
- library: async () => (await import("./library.command-8tw59xzj.js")).LibraryCommand,
21
- localRegistry: async () => (await import("./localRegistry.command-tf3dmznd.js")).LocalRegistryCommand,
22
- package: async () => (await import("./package.command-erbxe2tz.js")).PackageCommand,
23
- module: async () => (await import("./module.command-9vm8hffy.js")).ModuleCommand,
24
- page: async () => (await import("./page.command-jpavcj0p.js")).PageCommand,
25
- context: async () => (await import("./context.command-8fgn42jw.js")).ContextCommand,
26
- cloud: async () => (await import("./cloud.command-k2fhaape.js")).CloudCommand,
27
- subspace: async () => (await import("./subspace.command-51n0ykbx.js")).SubspaceCommand,
28
- guideline: async () => (await import("./guideline.command-3yxxr2mm.js")).GuidelineCommand,
29
- scalar: async () => (await import("./scalar.command-q8khmyx5.js")).ScalarCommand,
30
- primitive: async () => (await import("./primitive.command-sm32chzk.js")).PrimitiveCommand,
31
- quality: async () => (await import("./quality.command-pkd17n6y.js")).QualityCommand,
32
- repair: async () => (await import("./repair.command-8y4mq6hs.js")).RepairCommand,
33
- workflow: async () => (await import("./workflow.command-n5sv4wqz.js")).WorkflowCommand,
34
- pipeline: async () => (await import("./pipeline.command-b8rzvjvv.js")).PipelineCommand,
35
- tunnel: async () => (await import("./tunnel.command-7820vtxq.js")).TunnelCommand
16
+ workspace: async () => (await import("./workspace.command-1r9hvvw0.js")).WorkspaceCommand,
17
+ agent: async () => (await import("./agent.command-67ysh3n6.js")).AgentCommand,
18
+ code: async () => (await import("./code.command-ttk8tje2.js")).CodeCommand,
19
+ application: async () => (await import("./application.command-q0tqw5pc.js")).ApplicationCommand,
20
+ library: async () => (await import("./library.command-6amzsrb8.js")).LibraryCommand,
21
+ localRegistry: async () => (await import("./localRegistry.command-yqc0nyhh.js")).LocalRegistryCommand,
22
+ package: async () => (await import("./package.command-pwfvecjf.js")).PackageCommand,
23
+ module: async () => (await import("./module.command-10x6jv6c.js")).ModuleCommand,
24
+ page: async () => (await import("./page.command-ahhgx9y1.js")).PageCommand,
25
+ context: async () => (await import("./context.command-bdsk2z2r.js")).ContextCommand,
26
+ cloud: async () => (await import("./cloud.command-e7tkxyx6.js")).CloudCommand,
27
+ subspace: async () => (await import("./subspace.command-sc0t527y.js")).SubspaceCommand,
28
+ guideline: async () => (await import("./guideline.command-man90n70.js")).GuidelineCommand,
29
+ scalar: async () => (await import("./scalar.command-fprap51w.js")).ScalarCommand,
30
+ primitive: async () => (await import("./primitive.command-g5xwv6tj.js")).PrimitiveCommand,
31
+ quality: async () => (await import("./quality.command-fw9ck061.js")).QualityCommand,
32
+ repair: async () => (await import("./repair.command-g8kecj96.js")).RepairCommand,
33
+ workflow: async () => (await import("./workflow.command-j0jgkr13.js")).WorkflowCommand,
34
+ pipeline: async () => (await import("./pipeline.command-1ptr3e9y.js")).PipelineCommand,
35
+ tunnel: async () => (await import("./tunnel.command-mqnsqbwf.js")).TunnelCommand
36
36
  };
37
37
  var commandModuleIds = Object.keys(commandModules);
38
38
 
@@ -3,12 +3,12 @@ import {
3
3
  Lib,
4
4
  Workspace,
5
5
  command
6
- } from "./index-31ce9vhg.js";
6
+ } from "./index-vkb9m4z7.js";
7
7
  import"./index-52w0fvh8.js";
8
- import"./index-2etqq75t.js";
8
+ import"./index-g6ax17x4.js";
9
9
  import {
10
10
  LibraryScript
11
- } from "./index-bea2gwc6.js";
11
+ } from "./index-9mt4smfy.js";
12
12
 
13
13
  // pkgs/@akanjs/cli/library/library.command.ts
14
14
  class LibraryCommand extends command("library", [LibraryScript], ({ public: target }) => ({
@@ -4,31 +4,32 @@ import {
4
4
  runner,
5
5
  script,
6
6
  command
7
- } from "./index-31ce9vhg.js";
7
+ } from "./index-vkb9m4z7.js";
8
8
  import"./index-52w0fvh8.js";
9
9
  import {
10
10
  PkgExecutor
11
- } from "./index-2etqq75t.js";
12
- import"./index-k9rrten6.js";
13
- import"./index-g0vwzy9m.js";
14
- import"./index-0909wckt.js";
15
- import"./index-nq045px5.js";
16
- import"./index-bea2gwc6.js";
11
+ } from "./index-g6ax17x4.js";
12
+ import"./index-5nd1wtkv.js";
13
+ import"./index-4v43h00g.js";
14
+ import"./index-m9jj544v.js";
15
+ import"./index-35m6bzm7.js";
16
+ import"./index-h3r3nr9y.js";
17
+ import"./index-9mt4smfy.js";
17
18
  import {
18
19
  ApplicationScript
19
- } from "./index-20cebtth.js";
20
+ } from "./index-h6czey01.js";
20
21
  import"./index-7md2g9vw.js";
21
- import"./index-6726qr1m.js";
22
+ import"./index-jrmzcp66.js";
22
23
  import {
23
24
  getNpmRegistryUrl,
24
25
  CloudRunner
25
- } from "./index-3reaaa1h.js";
26
- import"./index-2ahj896a.js";
26
+ } from "./index-rc51f9ht.js";
27
+ import"./index-tvehn2sp.js";
27
28
  import {
28
29
  PackageScript
29
- } from "./index-tz5evhdr.js";
30
- import"./index-58vvz603.js";
31
- import"./index-kc8z134d.js";
30
+ } from "./index-ebarbgba.js";
31
+ import"./index-xsd96yzw.js";
32
+ import"./index-nx64dz92.js";
32
33
 
33
34
  // pkgs/@akanjs/cli/localRegistry/localRegistry.runner.ts
34
35
  import { mkdir, rm } from "fs/promises";
@@ -3,16 +3,16 @@ import {
3
3
  Sys,
4
4
  Module,
5
5
  command
6
- } from "./index-31ce9vhg.js";
6
+ } from "./index-vkb9m4z7.js";
7
7
  import"./index-52w0fvh8.js";
8
- import"./index-2etqq75t.js";
8
+ import"./index-g6ax17x4.js";
9
9
  import {
10
10
  renderPrimitiveReport
11
- } from "./index-rhbabmja.js";
12
- import"./index-jwqtchha.js";
11
+ } from "./index-033wne2j.js";
12
+ import"./index-27y8t17p.js";
13
13
  import {
14
14
  ModuleScript
15
- } from "./index-z507nzhg.js";
15
+ } from "./index-p2r64bpa.js";
16
16
 
17
17
  // pkgs/@akanjs/cli/module/module.command.ts
18
18
  import { Logger, lowerlize } from "akanjs/common";
@@ -3,13 +3,13 @@ import {
3
3
  Pkg,
4
4
  Workspace,
5
5
  command
6
- } from "./index-31ce9vhg.js";
6
+ } from "./index-vkb9m4z7.js";
7
7
  import"./index-52w0fvh8.js";
8
- import"./index-2etqq75t.js";
9
- import"./index-2ahj896a.js";
8
+ import"./index-g6ax17x4.js";
9
+ import"./index-tvehn2sp.js";
10
10
  import {
11
11
  PackageScript
12
- } from "./index-tz5evhdr.js";
12
+ } from "./index-ebarbgba.js";
13
13
 
14
14
  // pkgs/@akanjs/cli/package/package.command.ts
15
15
  class PackageCommand extends command("package", [PackageScript], ({ public: target }) => ({