@akanjs/cli 3.2.0-rc.9 → 3.2.1-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/.build-stamp +2 -2
  2. package/CodeAgent-xdw73nbz.js +11 -0
  3. package/{CodeTui-qstk5vpj.js → CodeTui-0gewm71c.js} +822 -666
  4. package/README.ko.md +7 -0
  5. package/README.md +7 -0
  6. package/TunnelShare-cccfdgbm.js +16 -0
  7. package/agent.command-g1mj34wz.js +59 -0
  8. package/akanCode.js +12 -12
  9. package/appExecutor-rrx10jya.js +11 -0
  10. package/{application.command-m4rq4wc2.js → application.command-3w4v7t40.js} +84 -40
  11. package/{applicationBuildRunner-df7rx3ra.js → applicationBuildRunner-y5xbetyz.js} +51 -20
  12. package/buildBatch.proc.js +31 -16
  13. package/{cloud.command-a0gy0qq2.js → cloud.command-ph0rz6sw.js} +28 -29
  14. package/cloud.script-8bs9tp4j.js +30 -0
  15. package/{code.command-5rsdqw8s.js → code.command-9b967qpg.js} +13 -9
  16. package/context.command-ndzs5rbf.js +62 -0
  17. package/context.runner-bmstpng2.js +32 -0
  18. package/csrArtifactBuilder-gtvff6k7.js +10 -0
  19. package/{index-qd7xn2bk.js → dependencyScanner-93g8tk0r.js} +7 -6
  20. package/{devTui-h77zrjv5.js → devTui-rf374y2w.js} +1 -1
  21. package/{fileSys-zpvt5gtf.js → fileSys-e5mwt73x.js} +1 -1
  22. package/frameworkGraph-aneq2nwy.js +8 -0
  23. package/{guideline.command-mffxknbr.js → guideline.command-y8qz9kxy.js} +9 -5
  24. package/guidelines/agentRule/agentRule.instruction.md +25 -9
  25. package/guidelines/akanApi/akanApi.instruction.md +6 -4
  26. package/guidelines/conventions/core.md +23 -5
  27. package/guidelines/conventions/rules/app.md +4 -1
  28. package/guidelines/conventions/rules/page.md +5 -4
  29. package/guidelines/conventions/rules/ts.md +3 -3
  30. package/guidelines/errorCodes/errorCodes.instruction.md +165 -0
  31. package/guidelines/fieldRule/fieldRule.instruction.md +2 -1
  32. package/guidelines/mcpRule/mcpRule.instruction.md +225 -5
  33. package/guidelines/pageRule/pageRule.instruction.md +10 -1
  34. package/guidelines/queryRule/queryRule.instruction.md +3 -1
  35. package/guidelines/runtimeRule/runtimeRule.instruction.md +14 -8
  36. package/guidelines/transportRule/transportRule.instruction.md +31 -1
  37. package/incrementalBuilder.proc.js +609 -437
  38. package/{index-skmtj8rm.js → index-02v45hh9.js} +27 -10
  39. package/{index-j6gc8n14.js → index-0csk6jqm.js} +11 -9
  40. package/{index-2r9ff9qm.js → index-0wa5z6rm.js} +2 -2
  41. package/{index-nmvhjn8c.js → index-0z8sbdme.js} +93 -82
  42. package/{index-2vgv7fs7.js → index-1c2807kg.js} +727 -693
  43. package/{index-hj6w4ka1.js → index-1p81ecbz.js} +1 -1
  44. package/{index-2mf1aen9.js → index-1p9bxjmt.js} +2 -2
  45. package/{index-an76bdrv.js → index-2kh4xj3m.js} +1 -1
  46. package/{index-99qvtff2.js → index-2vn0m9z5.js} +5 -5
  47. package/{index-rp4yf32g.js → index-3569fr49.js} +36 -29
  48. package/{index-xvk2a75m.js → index-38x8ynrx.js} +25 -25
  49. package/{index-cmg5ngqa.js → index-3fmzz9sf.js} +20 -20
  50. package/{index-rfzp4pqs.js → index-45aprybg.js} +3 -3
  51. package/{index-k92x3vne.js → index-4a1n0nym.js} +1 -1
  52. package/{index-ra9fvn7s.js → index-4zgm54wf.js} +76 -40
  53. package/{index-exn38bzx.js → index-652f3bs8.js} +116 -54
  54. package/{index-grxs6fts.js → index-6gepp8yn.js} +57 -31
  55. package/{index-vm0dn0mt.js → index-6j351de4.js} +294 -157
  56. package/{index-w15mg3km.js → index-7ssr7wq4.js} +1 -1
  57. package/{index-gxav1bjz.js → index-82cmbpxc.js} +9 -9
  58. package/{index-2mrn1mrg.js → index-9f3reh2y.js} +1 -1
  59. package/{index-gcx48get.js → index-9rymt8d6.js} +2 -2
  60. package/{index-swwjakt0.js → index-ankyx6dj.js} +14 -18
  61. package/{index-28x1aszt.js → index-b0t92k71.js} +154 -58
  62. package/index-b372rck5.js +799 -0
  63. package/{index-yf9wc28h.js → index-bejy9zyc.js} +1 -1
  64. package/{index-r0a604h4.js → index-c669pbyb.js} +5 -4
  65. package/{index-xyn02k0w.js → index-cm9rb480.js} +662 -433
  66. package/{index-j9790rhk.js → index-d0n78fzc.js} +1635 -1139
  67. package/{index-hqv34wzq.js → index-dr1carpr.js} +10 -10
  68. package/index-f2arv0mv.js +30 -0
  69. package/{index-5radqwn2.js → index-gtydr9qc.js} +12 -12
  70. package/{index-j6eeh5d7.js → index-j3fqs8rc.js} +5 -5
  71. package/{index-yckz5t8b.js → index-jdw9m5c4.js} +516 -434
  72. package/{index-ny2k80mv.js → index-jf4vk1s0.js} +9 -2
  73. package/{index-x40bdsca.js → index-jg5rwrf7.js} +77 -115
  74. package/{index-5zwr4n6k.js → index-ktxdfqg5.js} +65 -8
  75. package/index-mnhrqjjq.js +127 -0
  76. package/{index-3ghdb7p5.js → index-pc42gxa5.js} +2777 -3676
  77. package/{index-0hbtve0a.js → index-q8h4eg5y.js} +32 -28
  78. package/{index-j3v29pq7.js → index-qh81drde.js} +219 -175
  79. package/{index-b4qq3rq0.js → index-rwgqba9p.js} +1 -1
  80. package/{index-w8yasvpc.js → index-scfsqen7.js} +2136 -2175
  81. package/{index-9p260r4e.js → index-trffs83s.js} +538 -250
  82. package/{index-0gg15zwa.js → index-twjgmryg.js} +6 -6
  83. package/index-whvhsb5f.js +80 -0
  84. package/{index-h7hehkw6.js → index-xczjdng6.js} +3 -1
  85. package/{index-39jz41jb.js → index-xs9a3ddt.js} +3 -3
  86. package/{index-35j83zkd.js → index-xv3pvdw4.js} +2 -2
  87. package/{index-34792nh7.js → index-y2g0s9tn.js} +1 -1
  88. package/{index-43f4h4cm.js → index-ymgsvhc5.js} +7 -8
  89. package/{index-ygdbn9jn.js → index-zyb0ebm4.js} +1 -1
  90. package/{index-bns3wcpc.js → index-zyjztrvc.js} +2 -2
  91. package/index.js +30 -24
  92. package/libExecutor-nstr00s7.js +10 -0
  93. package/{library.command-bmd7zc5m.js → library.command-b02aw1hm.js} +12 -5
  94. package/{localRegistry.command-y6en1599.js → localRegistry.command-3hg1p4aj.js} +24 -24
  95. package/{module.command-7exfffqw.js → module.command-bd9gz6cv.js} +11 -7
  96. package/{package.command-adskw2rj.js → package.command-xmr0mxze.js} +11 -10
  97. package/package.json +8 -8
  98. package/{page.command-dw01272p.js → page.command-x94qf58g.js} +8 -4
  99. package/{pipeline.command-0b1r3y5r.js → pipeline.command-n2843k6t.js} +15 -9
  100. package/pkgExecutor-cka27e3c.js +10 -0
  101. package/{primitive.command-byw6vc04.js → primitive.command-cs7v376h.js} +12 -8
  102. package/{projectTypecheck-kkrpq60a.js → projectTypecheck-za2n3nbr.js} +1 -1
  103. package/{prompter-qrwx1p17.js → prompter-d33wmdpa.js} +2 -2
  104. package/{quality.command-6rqnhzct.js → quality.command-nqngh1jd.js} +25 -16
  105. package/{recipeScanner-4b69ybe0.js → recipeScanner-rrx69awy.js} +1 -1
  106. package/{repair.command-rw5zymak.js → repair.command-v2medwsm.js} +12 -8
  107. package/{routeSourceValidator-4h947v7c.js → routeSourceValidator-8n6j1vn7.js} +4 -2
  108. package/{scalar.command-2dyp9nh9.js → scalar.command-61cjmxn1.js} +10 -6
  109. package/skills/akan-debug/SKILL.md +8 -5
  110. package/skills/akan-err/SKILL.md +7 -0
  111. package/skills/akan-mcp/SKILL.md +19 -1
  112. package/skills/akan-scaffold/SKILL.md +1 -1
  113. package/skills/akan-validate/SKILL.md +3 -3
  114. package/{subspace.command-111ynwv1.js → subspace.command-dtv8nfh7.js} +30 -24
  115. package/templates/app/page/_layout.tsx +13 -0
  116. package/templates/app/page/styles.css.template +40 -0
  117. package/templates/appSample/page/_index.tsx +9 -9
  118. package/templates/appSample/page/_layout.tsx +1 -0
  119. package/templates/appSample/page/styles.css.template +40 -5
  120. package/templates/appSample/ui/Recipe/jellyButton.ts +1 -1
  121. package/templates/biomeForm.ts +1 -1
  122. package/templates/env/_env.server.type.ts +1 -1
  123. package/templates/facetIndex/index.ts +2 -37
  124. package/templates/lib/sig.ts +0 -4
  125. package/templates/lib/useClient.ts +1 -1
  126. package/templates/workspaceRoot/.devcontainer/devcontainer.json.template +1 -1
  127. package/templates/workspaceRoot/AGENTS.md.template +2 -1
  128. package/templates/workspaceRoot/README.ts +4 -2
  129. package/{tunnel.command-2gcpfbdj.js → tunnel.command-fmwm5fgb.js} +15 -13
  130. package/{typeChecker-s640r6c0.js → typeChecker-7jt6abrs.js} +1 -1
  131. package/typecheck.proc.js +3 -2
  132. package/{verify.command-djgs86ma.js → verify.command-4f260t53.js} +19 -17
  133. package/{workflow.command-n0k2mxr5.js → workflow.command-tm5q9xsm.js} +21 -14
  134. package/{workspace.command-fh1qwxfx.js → workspace.command-75gc280j.js} +56 -54
  135. package/CodeAgent-x2p3a3e0.js +0 -11
  136. package/TunnelShare-c4xsfzg5.js +0 -15
  137. package/agent.command-9et2e27p.js +0 -52
  138. package/cloud.script-xze4zh7n.js +0 -31
  139. package/context.command-rk1dwrg4.js +0 -57
  140. package/context.runner-83ky5m1b.js +0 -30
  141. package/dependencyScanner-78sq8m4q.js +0 -8
  142. /package/templates/{appSample → app}/public/fonts/Pretendard-Bold.woff2 +0 -0
  143. /package/templates/{appSample → app}/public/fonts/Pretendard-Medium.woff2 +0 -0
  144. /package/templates/{appSample → app}/public/fonts/Pretendard-Regular.woff2 +0 -0
  145. /package/templates/{appSample → app}/public/fonts/Pretendard-SemiBold.woff2 +0 -0
@@ -1,22 +1,31 @@
1
1
  // @bun
2
- import {
3
- ApplicationBuildReporter
4
- } from "./index-vm0dn0mt.js";
5
2
  import {
6
3
  parseBiomeReport,
7
4
  Linter,
8
- ProjectTypecheck2,
9
- AppExecutor,
10
- LibExecutor,
11
- PkgExecutor
12
- } from "./index-3ghdb7p5.js";
5
+ ProjectTypecheck2
6
+ } from "./index-pc42gxa5.js";
13
7
  import {
14
8
  TypecheckFailure
15
9
  } from "./index-j4yvgfhr.js";
10
+ import {
11
+ ApplicationBuildReporter
12
+ } from "./index-6j351de4.js";
13
+ import {
14
+ AppExecutor2
15
+ } from "./index-b372rck5.js";
16
+ import {
17
+ LibExecutor2
18
+ } from "./index-f2arv0mv.js";
19
+ import {
20
+ PkgExecutor2
21
+ } from "./index-mnhrqjjq.js";
16
22
  import {
17
23
  WorkspaceRunner,
18
24
  AkanQualityScanner
19
- } from "./index-xyn02k0w.js";
25
+ } from "./index-cm9rb480.js";
26
+ import {
27
+ VerifyScope
28
+ } from "./index-d0n78fzc.js";
20
29
 
21
30
  // pkgs/@akanjs/cli/verify/verifyComments.ts
22
31
  import { existsSync } from "fs";
@@ -27,6 +36,7 @@ class VerifyComments {
27
36
  static fix = "keep only a fact the code cannot say (vendor quirk, constraint, security, domain meaning, rejected alternative); delete the rest";
28
37
  static #codeFile = /\.[cm]?[jt]sx?$/;
29
38
  static #directive = /^(\/\/\/?|\/\*+)\s*(biome-ignore|@ts-|eslint-|prettier-ignore|#region|#endregion|<reference|[#@]__PURE__|@__NO_SIDE_EFFECTS__)/;
39
+ static #trackedTodo = /^(\/\/|\/\*+)\s*TODO:?\s*https?:\/\/\S[^\n]*$/;
30
40
  static #typescriptLoad;
31
41
  static #templateCommentsLoad;
32
42
  static #loadTypescript() {
@@ -51,6 +61,8 @@ class VerifyComments {
51
61
  for (const comment of VerifyComments.commentsOf(typescript, file, text)) {
52
62
  if (VerifyComments.#directive.test(comment.text))
53
63
  continue;
64
+ if (VerifyComments.#trackedTodo.test(comment.text))
65
+ continue;
54
66
  if (VerifyComments.#scaffolded(comment, templateComments))
55
67
  continue;
56
68
  if (lines && !VerifyComments.#touches(comment, lines))
@@ -187,6 +199,7 @@ class VerifyComments {
187
199
 
188
200
  // pkgs/@akanjs/cli/verify/verifyPipeline.ts
189
201
  import { existsSync as existsSync4 } from "fs";
202
+ import os from "os";
190
203
  import path5 from "path";
191
204
 
192
205
  // pkgs/@akanjs/cli/verify/verifyDiagnostics.ts
@@ -560,6 +573,10 @@ class VerifyStyleClasses {
560
573
 
561
574
  // pkgs/@akanjs/cli/verify/verifyPipeline.ts
562
575
  class VerifyPipeline {
576
+ static concurrencyOf(cpus, memoryBytes) {
577
+ return Math.max(1, Math.min(4, Math.max(2, cpus - 1), Math.floor(memoryBytes / 2 ** 32)));
578
+ }
579
+ static #concurrency = VerifyPipeline.concurrencyOf(os.availableParallelism(), os.totalmem());
563
580
  #workspace;
564
581
  #workspaceRunner;
565
582
  #applicationRunner;
@@ -573,20 +590,22 @@ class VerifyPipeline {
573
590
  get #root() {
574
591
  return this.#workspace.workspaceRoot;
575
592
  }
576
- async run(scope, { lintOnly = false, build = true } = {}) {
593
+ async run(changed, { lintOnly = false, build = true } = {}) {
577
594
  const startedAt = performance.now();
595
+ const scope = lintOnly ? changed : await this.#withDependents(changed);
578
596
  const systems = scope.targets.filter((target) => target.type !== "pkg");
597
+ const edited = scope.targets.filter((target) => !target.dependent);
579
598
  if (!lintOnly)
580
599
  await this.#each("sync", systems, (target) => this.#sync(target));
581
600
  const synced = !this.#failed("sync");
582
601
  const renames = new Map;
583
- for (const target of systems)
602
+ for (const target of edited.filter((target) => target.type !== "pkg"))
584
603
  renames.set(target, await VerifyPrivateMethods.fix(this.#root, target.dir, target.files).catch(() => new Map));
585
604
  await Promise.all([
586
- this.#each("lint", scope.targets, (target) => this.#lint(target, { comments: !lintOnly, rewritten: renames.get(target) ?? new Map })),
587
- lintOnly || !synced ? null : this.#each("typecheck", scope.targets, (target) => this.#typecheck(target))
605
+ this.#each("lint", edited, (target) => this.#lint(target, { comments: !lintOnly, rewritten: renames.get(target) ?? new Map }), VerifyPipeline.#concurrency),
606
+ lintOnly || !synced ? null : this.#each("typecheck", scope.targets, (target) => this.#typecheck(target), VerifyPipeline.#concurrency)
588
607
  ]);
589
- const apps = scope.targets.filter((target) => target.type === "app");
608
+ const apps = edited.filter((target) => target.type === "app");
590
609
  const clean = !this.#diagnostics.some((diagnostic) => diagnostic.severity === "error");
591
610
  if (!lintOnly && build && apps.length) {
592
611
  if (clean)
@@ -604,20 +623,34 @@ class VerifyPipeline {
604
623
  diagnostics: this.#diagnostics
605
624
  };
606
625
  }
607
- async#each(name, items, step) {
626
+ async#withDependents(scope) {
627
+ if (!scope.changedLibs.length)
628
+ return scope;
629
+ const [apps, libs, pkgs] = await this.#workspace.getExecs();
630
+ const names = { apps, libs, pkgs };
631
+ return scope.withDependents(names, await VerifyScope.libDepsIn(this.#root, names));
632
+ }
633
+ async#each(name, items, step, concurrency = 1) {
608
634
  if (!items.length)
609
635
  return;
610
636
  const startedAt = performance.now();
611
- let fixed = 0;
612
- let failed = false;
613
- for (const item of items) {
614
- const outcome = await step(item).catch((error) => ({
615
- diagnostics: [VerifyDiagnostics.fromMessage(name, ApplicationBuildReporter.formatError(error, this.#root))]
616
- }));
617
- fixed += outcome.fixed ?? 0;
618
- failed ||= outcome.diagnostics.some((diagnostic) => diagnostic.severity === "error");
619
- this.#diagnostics.push(...outcome.diagnostics);
620
- }
637
+ const outcomes = [];
638
+ let next = 0;
639
+ const worker = async () => {
640
+ while (next < items.length) {
641
+ const idx = next++;
642
+ outcomes[idx] = await step(items[idx]).catch((error) => ({
643
+ diagnostics: [VerifyDiagnostics.fromMessage(name, ApplicationBuildReporter.formatError(error, this.#root))]
644
+ }));
645
+ }
646
+ };
647
+ await Promise.all(Array.from({ length: Math.min(concurrency, items.length) }, worker));
648
+ const fixed = outcomes.reduce((sum, outcome) => sum + (outcome.fixed ?? 0), 0);
649
+ const diagnostics = [
650
+ ...new Map(outcomes.flatMap((outcome) => outcome.diagnostics).map((entry) => [JSON.stringify(entry), entry])).values()
651
+ ];
652
+ this.#diagnostics.push(...diagnostics);
653
+ const failed = diagnostics.some((diagnostic) => diagnostic.severity === "error");
621
654
  const ms = Math.round(performance.now() - startedAt);
622
655
  this.#steps.set(name, { name, status: failed ? "fail" : "pass", ms, fixed });
623
656
  }
@@ -629,9 +662,9 @@ class VerifyPipeline {
629
662
  }
630
663
  async#sync(target) {
631
664
  if (target.type === "app")
632
- await AppExecutor.from(this.#workspace, target.name).scanSync();
665
+ await AppExecutor2.from(this.#workspace, target.name).scanSync();
633
666
  else
634
- await LibExecutor.from(this.#workspace, target.name).scan();
667
+ await LibExecutor2.from(this.#workspace, target.name).scan();
635
668
  return { diagnostics: [] };
636
669
  }
637
670
  async#lint(target, { comments, rewritten }) {
@@ -696,12 +729,12 @@ class VerifyPipeline {
696
729
  async#typecheck(target) {
697
730
  try {
698
731
  if (target.type === "app")
699
- await this.#applicationRunner.typecheck(AppExecutor.from(this.#workspace, target.name), {
732
+ await this.#applicationRunner.typecheck(AppExecutor2.from(this.#workspace, target.name), {
700
733
  tests: true,
701
734
  report: "records"
702
735
  });
703
736
  else if (target.type === "lib")
704
- await this.#applicationRunner.typecheckLibrary(LibExecutor.from(this.#workspace, target.name), {
737
+ await this.#applicationRunner.typecheckLibrary(LibExecutor2.from(this.#workspace, target.name), {
705
738
  tests: true,
706
739
  report: "records"
707
740
  });
@@ -709,7 +742,7 @@ class VerifyPipeline {
709
742
  const tsconfigPath = path5.join(this.#root, target.dir, "tsconfig.json");
710
743
  if (!existsSync4(tsconfigPath))
711
744
  return { diagnostics: [] };
712
- await new ProjectTypecheck2(path5.join(this.#root, target.dir), this.#root, process.env).check(tsconfigPath, "records");
745
+ await new ProjectTypecheck2(path5.join(this.#root, target.dir), this.#root, process.env).checkIncremental(tsconfigPath, path5.join(this.#root, ".akan", "typecheck", target.dir), "records");
713
746
  }
714
747
  return { diagnostics: [] };
715
748
  } catch (error) {
@@ -719,20 +752,20 @@ class VerifyPipeline {
719
752
  }
720
753
  }
721
754
  async#build(target) {
722
- const { routeJsWarnings = [] } = await this.#applicationRunner.build(AppExecutor.from(this.#workspace, target.name), { fast: true });
755
+ const { routeJsWarnings = [] } = await this.#applicationRunner.build(AppExecutor2.from(this.#workspace, target.name), { verify: true });
723
756
  return { diagnostics: routeJsWarnings.map((warning) => VerifyDiagnostics.fromRouteJsBudget(warning)) };
724
757
  }
725
758
  async#ssr(scope) {
726
- const scanned = await new AkanQualityScanner().scan(this.#root);
727
- const warnings = scanned.warnings.filter((warning) => warning.scope === "ssr");
759
+ const dirs = scope.targets.filter((target) => target.type !== "pkg" && target.files.some((file) => file.endsWith(".tsx"))).map((target) => target.dir);
760
+ const warnings = await new AkanQualityScanner().scanSsr(this.#root, dirs);
728
761
  return { diagnostics: VerifyDiagnostics.fromQuality(warnings, scope.changedFiles) };
729
762
  }
730
763
  #execOf(target) {
731
764
  if (target.type === "app")
732
- return AppExecutor.from(this.#workspace, target.name);
765
+ return AppExecutor2.from(this.#workspace, target.name);
733
766
  if (target.type === "lib")
734
- return LibExecutor.from(this.#workspace, target.name);
735
- return PkgExecutor.from(this.#workspace, target.name);
767
+ return LibExecutor2.from(this.#workspace, target.name);
768
+ return PkgExecutor2.from(this.#workspace, target.name);
736
769
  }
737
770
  }
738
771
 
@@ -753,18 +786,21 @@ class VerifyReport {
753
786
  static #header(result) {
754
787
  const ran = result.steps.filter((step) => step.name !== "sync" || step.status === "fail");
755
788
  const fixed = result.steps.reduce((sum, step) => sum + step.fixed, 0);
756
- const seconds = `${(result.ms / 1000).toFixed(1)}s`;
789
+ const seconds = VerifyReport.#seconds(result.ms);
757
790
  const fixedNote = fixed ? `fixed ${fixed} file${fixed === 1 ? "" : "s"}` : null;
758
- const steps = result.ok ? ran.filter((step) => step.status === "pass").map((step) => step.name).join(" ") : ran.map((step) => VerifyReport.#stepLabel(step, result.diagnostics)).join(" \xB7 ");
791
+ const steps = result.ok ? ran.filter((step) => step.status === "pass").map((step) => `${step.name} ${VerifyReport.#seconds(step.ms)}`).join(" ") : ran.map((step) => VerifyReport.#stepLabel(step, result.diagnostics)).join(" \xB7 ");
759
792
  return [`verify ${result.ok ? "ok" : "fail"}`, result.targets.join(", "), steps, fixedNote, seconds].filter(Boolean).join(" \xB7 ");
760
793
  }
761
794
  static #stepLabel(step, diagnostics) {
762
795
  if (step.status === "skip")
763
796
  return `${step.name} skipped`;
764
797
  if (step.status === "pass")
765
- return `${step.name} ok`;
798
+ return `${step.name} ok ${VerifyReport.#seconds(step.ms)}`;
766
799
  const errors = diagnostics.filter((entry) => entry.step === step.name && entry.severity === "error").length;
767
- return `${step.name} ${errors} error${errors === 1 ? "" : "s"}`;
800
+ return `${step.name} ${errors} error${errors === 1 ? "" : "s"} ${VerifyReport.#seconds(step.ms)}`;
801
+ }
802
+ static #seconds(ms) {
803
+ return `${(ms / 1000).toFixed(1)}s`;
768
804
  }
769
805
  static #diagnosticLines(diagnostics, max) {
770
806
  const groups = new Map;
@@ -2,18 +2,27 @@
2
2
  import {
3
3
  CliError
4
4
  } from "./index-j4yvgfhr.js";
5
+ import {
6
+ Executor,
7
+ WorkspaceExecutor
8
+ } from "./index-pc42gxa5.js";
5
9
  import {
6
10
  getDirname2,
7
11
  FileSys2
8
- } from "./index-bns3wcpc.js";
12
+ } from "./index-zyjztrvc.js";
9
13
  import {
10
- Executor,
11
- WorkspaceExecutor,
12
- AppExecutor,
13
- LibExecutor,
14
- PkgExecutor,
15
- ModuleExecutor
16
- } from "./index-3ghdb7p5.js";
14
+ AppExecutor2
15
+ } from "./index-b372rck5.js";
16
+ import {
17
+ LibExecutor2
18
+ } from "./index-f2arv0mv.js";
19
+ import {
20
+ PkgExecutor2
21
+ } from "./index-mnhrqjjq.js";
22
+ import {
23
+ ModuleExecutor,
24
+ ErrorReport
25
+ } from "./index-whvhsb5f.js";
17
26
 
18
27
  // pkgs/@akanjs/devkit/commandDecorators/camelToKebabCase.ts
19
28
  var camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
@@ -69,7 +78,7 @@ import { Logger } from "akanjs/common";
69
78
  import chalk2 from "chalk";
70
79
  import { program } from "commander";
71
80
 
72
- // pkgs/@akanjs/devkit/appSelectionMemory.ts
81
+ // pkgs/@akanjs/devkit/workspace/appSelectionMemory.ts
73
82
  import path from "path";
74
83
  class AppSelectionMemory {
75
84
  static pathIn(workspaceRoot) {
@@ -295,35 +304,46 @@ import { existsSync, readFileSync, realpathSync } from "fs";
295
304
  import path2 from "path";
296
305
 
297
306
  class WorkspaceVersionCheck {
307
+ static overrideEnv = "AKAN_ALLOW_VERSION_MISMATCH";
298
308
  static #exemptCommands = new Set(["update", "create-workspace"]);
299
309
  static #infoFlags = new Set(["--help", "-h", "--version", "-V"]);
300
310
  static #updateTags = new Set(["dev", "canary", "beta", "rc", "alpha"]);
301
311
  static warning(cliVersion, argv, workspaceRoot) {
302
- const args = argv.slice(2);
303
- if (!cliVersion || WorkspaceVersionCheck.#exemptCommands.has(args[0] ?? ""))
304
- return null;
305
- if (args.some((arg) => WorkspaceVersionCheck.#infoFlags.has(arg)))
306
- return null;
307
- const installed = WorkspaceVersionCheck.installedAkanVersion(workspaceRoot);
308
- if (!installed || installed === cliVersion)
312
+ const mismatch = WorkspaceVersionCheck.#mismatchOf(cliVersion, argv, workspaceRoot);
313
+ if (!mismatch)
309
314
  return null;
310
- const pinnedCli = WorkspaceVersionCheck.#versionAt(path2.join(workspaceRoot, "node_modules/@akanjs/cli"));
311
- const runner = pinnedCli === installed ? ["bunx"] : ["bunx", "-p", `@akanjs/cli@${installed}`];
312
- const rerun = [...runner, "akan", ...args].map(WorkspaceVersionCheck.#quote).join(" ");
313
- const [, prerelease = ""] = cliVersion.split("-");
314
- const tag = prerelease.split(".")[0];
315
- const update = `akan update${WorkspaceVersionCheck.#updateTags.has(tag) ? ` --tag ${tag}` : ""}`;
315
+ const { cliVersion: cli, installed, pinnedCli, rerun, update } = mismatch;
316
316
  const lines = [
317
- `This akan is @akanjs/cli ${cliVersion}, but this workspace has akanjs ${installed}: what it generates may not match the installed framework.`,
317
+ `This akan is @akanjs/cli ${cli}, but this workspace has akanjs ${installed}: what it generates may not match the installed framework.`,
318
318
  `Run the matching CLI: ${rerun}`
319
319
  ];
320
- if (Bun.semver.order(cliVersion, installed) > 0)
320
+ if (Bun.semver.order(cli, installed) > 0)
321
321
  lines.push(`Or move the workspace and this CLI to the newest release of the line together: ${update}`);
322
322
  else if (pinnedCli !== installed)
323
323
  lines.push(`Pin it so \`bunx akan\` runs it: bun add -d @akanjs/cli@${installed}`);
324
324
  return lines.join(`
325
325
  `);
326
326
  }
327
+ static refusal(cliVersion, argv, workspaceRoot, env = process.env) {
328
+ const mismatch = WorkspaceVersionCheck.#mismatchOf(cliVersion, argv, workspaceRoot);
329
+ if (!mismatch || ["1", "true"].includes(env[WorkspaceVersionCheck.overrideEnv] ?? ""))
330
+ return null;
331
+ const { args, cliVersion: cli, installed, rerun, update } = mismatch;
332
+ if (WorkspaceVersionCheck.#lineOf(cli) === WorkspaceVersionCheck.#lineOf(installed))
333
+ return null;
334
+ const realign = Bun.semver.order(cli, installed) > 0 ? `Move the workspace and this CLI to one release together: ${update}` : `Install the CLI this workspace was moved to: bun add -g @akanjs/cli@${installed}`;
335
+ return [
336
+ `This akan is @akanjs/cli ${cli}, but this workspace has akanjs ${installed}, another major.minor, so \`akan ${args[0]}\` is refused: it writes to the workspace, and what it writes would not match the installed framework.`,
337
+ realign,
338
+ `Or run the matching CLI once: ${rerun}`,
339
+ `Or set ${WorkspaceVersionCheck.overrideEnv}=1 to run it anyway.`
340
+ ].join(`
341
+ `);
342
+ }
343
+ static readsOnly(targetOption, values) {
344
+ const { readOnly = false } = targetOption;
345
+ return typeof readOnly === "function" ? readOnly(values) : readOnly;
346
+ }
327
347
  static installedAkanVersion(workspaceRoot) {
328
348
  const packageDir = path2.join(workspaceRoot, "node_modules", "akanjs");
329
349
  if (!existsSync(packageDir))
@@ -332,6 +352,26 @@ class WorkspaceVersionCheck {
332
352
  return null;
333
353
  return WorkspaceVersionCheck.#versionAt(packageDir);
334
354
  }
355
+ static #mismatchOf(cliVersion, argv, workspaceRoot) {
356
+ const args = argv.slice(2);
357
+ if (!cliVersion || WorkspaceVersionCheck.#exemptCommands.has(args[0] ?? ""))
358
+ return null;
359
+ if (args.some((arg) => WorkspaceVersionCheck.#infoFlags.has(arg)))
360
+ return null;
361
+ const installed = WorkspaceVersionCheck.installedAkanVersion(workspaceRoot);
362
+ if (!installed || installed === cliVersion)
363
+ return null;
364
+ const pinnedCli = WorkspaceVersionCheck.#versionAt(path2.join(workspaceRoot, "node_modules/@akanjs/cli"));
365
+ const runner = pinnedCli === installed ? ["bunx"] : ["bunx", "-p", `@akanjs/cli@${installed}`];
366
+ const rerun = [...runner, "akan", ...args].map(WorkspaceVersionCheck.#quote).join(" ");
367
+ const [, prerelease = ""] = cliVersion.split("-");
368
+ const tag = prerelease.split(".")[0];
369
+ const update = `akan update${WorkspaceVersionCheck.#updateTags.has(tag) ? ` --tag ${tag}` : ""}`;
370
+ return { args, cliVersion, installed, pinnedCli, rerun, update };
371
+ }
372
+ static #lineOf(version) {
373
+ return version.split("-")[0]?.split(".").slice(0, 2).join(".");
374
+ }
335
375
  static #versionAt(packageDir) {
336
376
  const packageJsonPath = path2.join(packageDir, "package.json");
337
377
  if (!existsSync(packageJsonPath))
@@ -363,7 +403,7 @@ var printCliError = (error, stream = "log") => {
363
403
  return;
364
404
  loggedCliErrorObjects.add(error);
365
405
  }
366
- const message = CliError.messageOf(error);
406
+ const message = error instanceof Error ? ErrorReport.format(error) || error.name : CliError.messageOf(error);
367
407
  if (loggedCliErrorMessages.has(message))
368
408
  return;
369
409
  loggedCliErrorMessages.add(message);
@@ -443,6 +483,29 @@ var givenOptionsOf = (argMetas, opt) => {
443
483
  }
444
484
  return given;
445
485
  };
486
+ var argValuesOf = (argMetas, cmdArgs, opt) => {
487
+ const values = givenOptionsOf(argMetas, opt);
488
+ for (const argMeta of argMetas) {
489
+ if (argMeta.type === "Argument")
490
+ values[argMeta.name] = cmdArgs[argMeta.idx] ?? argMeta.argsOption.default;
491
+ else if (argMeta.type === "Option")
492
+ values[argMeta.name] ??= argMeta.argsOption.default;
493
+ }
494
+ return values;
495
+ };
496
+ var resolvedValuesOf = (argMetas, commandArgs) => Object.fromEntries(argMetas.flatMap((argMeta) => argMeta.type === "Option" || argMeta.type === "Argument" ? [[argMeta.name, commandArgs[argMeta.idx]]] : []));
497
+ var versionGateOf = (cliVersion) => {
498
+ let warning = WorkspaceVersionCheck.warning(cliVersion, process.argv, process.cwd());
499
+ const refusal = WorkspaceVersionCheck.refusal(cliVersion, process.argv, process.cwd());
500
+ return (targetOption, values) => {
501
+ if (refusal && !WorkspaceVersionCheck.readsOnly(targetOption, values))
502
+ throw new CliError("refused", refusal);
503
+ if (warning)
504
+ Logger.rawLog(chalk2.yellow(`
505
+ ${warning}`), undefined, "error");
506
+ warning = null;
507
+ };
508
+ };
446
509
  var normalizeEnumChoices = (enumChoices) => enumChoices.map((choice) => typeof choice === "object" ? { value: choice.value, name: choice.label } : { value: choice, name: choice.toString() });
447
510
  var prompts = async () => await import("@inquirer/prompts");
448
511
  var select = (config, context) => prompts().then((m) => m.select(config, context));
@@ -514,11 +577,11 @@ var getArgumentValue = async (argMeta, value) => {
514
577
  return convertArgValue(await input({ message: inputMessageOf(argMeta) }), type ?? "string");
515
578
  };
516
579
  var assignCommandContext = (context, argMeta, value) => {
517
- if (value instanceof AppExecutor)
580
+ if (value instanceof AppExecutor2)
518
581
  context.app = value;
519
- else if (value instanceof LibExecutor)
582
+ else if (value instanceof LibExecutor2)
520
583
  context.lib = value;
521
- else if (value instanceof PkgExecutor)
584
+ else if (value instanceof PkgExecutor2)
522
585
  context.pkg = value;
523
586
  else if (value instanceof ModuleExecutor)
524
587
  context.module = value;
@@ -569,15 +632,15 @@ var getAppsArgumentValue = async (value, workspace, rerun) => {
569
632
  throw new Error("No apps found in this workspace (apps/<appName>/akan.config.ts)");
570
633
  const requested = parseAppNameList(value);
571
634
  if (requested.includes("all"))
572
- return appNames.map((name) => AppExecutor.from(workspace, name));
635
+ return appNames.map((name) => AppExecutor2.from(workspace, name));
573
636
  if (requested.length) {
574
637
  const unknown = requested.filter((name) => !appNames.includes(name));
575
638
  if (unknown.length)
576
639
  throw new CliError("unknownTarget", `Unknown app${unknown.length > 1 ? "s" : ""}: ${unknown.join(", ")}. Available: ${appNames.join(", ")}, all`);
577
- return [...new Set(requested)].map((name) => AppExecutor.from(workspace, name));
640
+ return [...new Set(requested)].map((name) => AppExecutor2.from(workspace, name));
578
641
  }
579
642
  if (appNames.length === 1 && appNames[0])
580
- return [AppExecutor.from(workspace, appNames[0])];
643
+ return [AppExecutor2.from(workspace, appNames[0])];
581
644
  assertPromptable("Missing apps", { choices: [...appNames, "all"], ...rerunRemedyOf(rerun, "<apps...>") });
582
645
  const remembered = new Set(await AppSelectionMemory.read(workspace.workspaceRoot));
583
646
  const picked = await checkbox({
@@ -586,7 +649,7 @@ var getAppsArgumentValue = async (value, workspace, rerun) => {
586
649
  required: true
587
650
  });
588
651
  await AppSelectionMemory.write(workspace.workspaceRoot, picked);
589
- return picked.map((name) => AppExecutor.from(workspace, name));
652
+ return picked.map((name) => AppExecutor2.from(workspace, name));
590
653
  };
591
654
  var getInternalArgumentValue = async (argMeta, value, workspace, rerun, { destructive = false } = {}) => {
592
655
  if (argMeta.type === "Workspace")
@@ -612,18 +675,18 @@ var getInternalArgumentValue = async (argMeta, value, workspace, rerun, { destru
612
675
  const pkgChoices = sysType === "exec" ? pkgNames : [];
613
676
  const execOf = (name) => {
614
677
  if (appNames.includes(name))
615
- return AppExecutor.from(workspace, name);
678
+ return AppExecutor2.from(workspace, name);
616
679
  if (libNames.includes(name))
617
- return LibExecutor.from(workspace, name);
680
+ return LibExecutor2.from(workspace, name);
618
681
  if (pkgChoices.includes(name))
619
- return PkgExecutor.from(workspace, name);
682
+ return PkgExecutor2.from(workspace, name);
620
683
  return null;
621
684
  };
622
685
  const found = value ? execOf(value) : null;
623
686
  if (found)
624
687
  return found;
625
688
  if (!value && !destructive && argMeta.option?.onlyApp && appNames.length === 1 && appNames[0])
626
- return AppExecutor.from(workspace, appNames[0]);
689
+ return AppExecutor2.from(workspace, appNames[0]);
627
690
  const [kind, placeholder] = sysType === "exec" ? ["app, lib or pkg", "<app-lib-or-pkg>"] : ["app or lib", "<app-or-lib>"];
628
691
  const choices = [...appNames, ...libNames, ...pkgChoices];
629
692
  const only = takeOnly(kind, choices, execOf);
@@ -640,35 +703,35 @@ var getInternalArgumentValue = async (argMeta, value, workspace, rerun, { destru
640
703
  return picked;
641
704
  } else if (sysType === "app") {
642
705
  if (value && appNames.includes(value))
643
- return AppExecutor.from(workspace, value);
706
+ return AppExecutor2.from(workspace, value);
644
707
  if (!value && !destructive && appNames.length === 1 && appNames[0])
645
- return AppExecutor.from(workspace, appNames[0]);
708
+ return AppExecutor2.from(workspace, appNames[0]);
646
709
  assertAskable("app", appNames, "<app>");
647
710
  const appName = await select({ message: `Select the ${sysType} name`, choices: appNames });
648
- return AppExecutor.from(workspace, appName);
711
+ return AppExecutor2.from(workspace, appName);
649
712
  } else if (sysType === "lib") {
650
713
  if (value && libNames.includes(value))
651
- return LibExecutor.from(workspace, value);
652
- const only = takeOnly("lib", libNames, (name) => LibExecutor.from(workspace, name));
714
+ return LibExecutor2.from(workspace, value);
715
+ const only = takeOnly("lib", libNames, (name) => LibExecutor2.from(workspace, name));
653
716
  if (only)
654
717
  return only;
655
718
  assertAskable("lib", libNames, "<lib>");
656
719
  const libName = await select({ message: `Select the ${sysType} name`, choices: libNames });
657
- return LibExecutor.from(workspace, libName);
720
+ return LibExecutor2.from(workspace, libName);
658
721
  } else if (sysType === "pkg") {
659
722
  const pkgs = await workspace.getPkgs();
660
723
  if (value && pkgs.includes(value))
661
- return PkgExecutor.from(workspace, value);
662
- const only = takeOnly("pkg", pkgs, (name) => PkgExecutor.from(workspace, name));
724
+ return PkgExecutor2.from(workspace, value);
725
+ const only = takeOnly("pkg", pkgs, (name) => PkgExecutor2.from(workspace, name));
663
726
  if (only)
664
727
  return only;
665
728
  assertAskable("pkg", pkgs, "<pkg>");
666
729
  const pkgName = await select({ message: `Select the ${sysType} name`, choices: pkgs });
667
- return PkgExecutor.from(workspace, pkgName);
730
+ return PkgExecutor2.from(workspace, pkgName);
668
731
  } else if (sysType === "module") {
669
732
  const systems = [
670
- ...appNames.map((name) => AppExecutor.from(workspace, name)),
671
- ...libNames.map((name) => LibExecutor.from(workspace, name))
733
+ ...appNames.map((name) => AppExecutor2.from(workspace, name)),
734
+ ...libNames.map((name) => LibExecutor2.from(workspace, name))
672
735
  ];
673
736
  const modulesOf = async (sys) => [
674
737
  ...await sys.getModules(),
@@ -706,7 +769,7 @@ var getInternalArgumentValue = async (argMeta, value, workspace, rerun, { destru
706
769
  ...libNames.map((name) => ({ name, value: { type: "lib", name } }))
707
770
  ]
708
771
  });
709
- const executor = type === "app" ? AppExecutor.from(workspace, name) : LibExecutor.from(workspace, name);
772
+ const executor = type === "app" ? AppExecutor2.from(workspace, name) : LibExecutor2.from(workspace, name);
710
773
  const modules = await modulesOf(executor);
711
774
  const moduleName = await select({
712
775
  message: `Select the module name`,
@@ -764,10 +827,7 @@ var runCommands = async (...commands) => {
764
827
  program.version(process.env.AKAN_VERSION).description("Akan CLI").configureHelp({
765
828
  helpWidth: 100
766
829
  });
767
- const versionWarning = WorkspaceVersionCheck.warning(cliPackageJson?.version, process.argv, process.cwd());
768
- if (versionWarning)
769
- Logger.rawLog(chalk2.yellow(`
770
- ${versionWarning}`), undefined, "error");
830
+ const checkVersion = versionGateOf(cliPackageJson?.version);
771
831
  for (const command of commands) {
772
832
  const targetMetas = getTargetMetas(command);
773
833
  for (const targetMeta of targetMetas) {
@@ -819,6 +879,7 @@ ${versionWarning}`), undefined, "error");
819
879
  usage: false,
820
880
  given: givenOptionsOf(allArgMetas, opt)
821
881
  });
882
+ checkVersion(targetMeta.targetOption, argValuesOf(allArgMetas, cmdArgs, opt));
822
883
  const commandArgs = [];
823
884
  if (targetMeta.targetOption.runsOnWorkspaceRoot) {
824
885
  await assertCurrentDirectoryIsWorkspaceRoot();
@@ -836,7 +897,7 @@ ${versionWarning}`), undefined, "error");
836
897
  commandArgs[argMeta.idx] = await getAppsArgumentValue(cmdArgs[argMeta.idx], workspace, rerun);
837
898
  else
838
899
  commandArgs[argMeta.idx] = await getInternalArgumentValue(argMeta, cmdArgs[argMeta.idx], workspace, rerun, { destructive: targetMeta.targetOption.destructive });
839
- if (commandArgs[argMeta.idx] instanceof AppExecutor)
900
+ if (commandArgs[argMeta.idx] instanceof AppExecutor2)
840
901
  process.env.AKAN_PUBLIC_APP_NAME = commandArgs[argMeta.idx].name;
841
902
  else if (Array.isArray(commandArgs[argMeta.idx])) {
842
903
  const apps = commandArgs[argMeta.idx];
@@ -847,6 +908,7 @@ ${versionWarning}`), undefined, "error");
847
908
  if (opt.verbose)
848
909
  Executor.setVerbose(true);
849
910
  }
911
+ checkVersion(targetMeta.targetOption, resolvedValuesOf(allArgMetas, commandArgs));
850
912
  const cmd = CommandContainer.get(command);
851
913
  try {
852
914
  await targetMeta.handler.call(cmd, ...commandArgs);
@@ -951,4 +1013,4 @@ class ExitCodeError extends CliError {
951
1013
  return CliError.exitCodeOf(error);
952
1014
  }
953
1015
  }
954
- export { camelToKebabCase, getTargetMetas, getTargetCommandNames, App, Apps, Lib, Sys, SysOrOnlyApp, Exec, Pkg, Module, ModuleOrService, Workspace, CommandContainer, runner, script, markCliErrorPrinted, assertPromptable, runCommands, command, ExitCodeError };
1016
+ export { camelToKebabCase, getTargetMetas, getTargetCommandNames, App, Apps, Lib, Sys, SysOrOnlyApp, Exec, Pkg, Module, ModuleOrService, Workspace, CommandContainer, runner, script, WorkspaceVersionCheck, markCliErrorPrinted, assertPromptable, runCommands, command, ExitCodeError };