@akanjs/cli 3.2.0-rc.8 → 3.2.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 (143) hide show
  1. package/.build-stamp +2 -2
  2. package/CodeAgent-fx6088tv.js +11 -0
  3. package/{CodeTui-qstk5vpj.js → CodeTui-zee8atsr.js} +822 -666
  4. package/README.ko.md +7 -0
  5. package/README.md +7 -0
  6. package/TunnelShare-9ry4vh0y.js +18 -0
  7. package/agent.command-x65f2ags.js +61 -0
  8. package/akanCode.js +12 -12
  9. package/appExecutor-79azsb2w.js +11 -0
  10. package/{application.command-m4rq4wc2.js → application.command-azbd1pb2.js} +83 -37
  11. package/{applicationBuildRunner-df7rx3ra.js → applicationBuildRunner-trfxv3pd.js} +49 -18
  12. package/buildBatch.proc.js +25 -11
  13. package/{cloud.command-a0gy0qq2.js → cloud.command-gapp4634.js} +33 -29
  14. package/cloud.script-3b401efv.js +35 -0
  15. package/{code.command-5rsdqw8s.js → code.command-5smx61yf.js} +13 -9
  16. package/context.command-ym5jbkny.js +64 -0
  17. package/context.runner-kctbfsde.js +34 -0
  18. package/{dependencyScanner-78sq8m4q.js → dependencyScanner-ge10gb52.js} +2 -2
  19. package/{devTui-h77zrjv5.js → devTui-rf374y2w.js} +1 -1
  20. package/{fileSys-zpvt5gtf.js → fileSys-q22646yc.js} +1 -1
  21. package/{guideline.command-mffxknbr.js → guideline.command-zwypaqsh.js} +9 -5
  22. package/guidelines/agentRule/agentRule.instruction.md +25 -9
  23. package/guidelines/akanApi/akanApi.instruction.md +6 -4
  24. package/guidelines/conventions/core.md +23 -5
  25. package/guidelines/conventions/rules/app.md +4 -1
  26. package/guidelines/conventions/rules/page.md +5 -4
  27. package/guidelines/conventions/rules/ts.md +3 -3
  28. package/guidelines/errorCodes/errorCodes.instruction.md +165 -0
  29. package/guidelines/fieldRule/fieldRule.instruction.md +2 -1
  30. package/guidelines/mcpRule/mcpRule.instruction.md +225 -5
  31. package/guidelines/pageRule/pageRule.instruction.md +10 -1
  32. package/guidelines/queryRule/queryRule.instruction.md +3 -1
  33. package/guidelines/runtimeRule/runtimeRule.instruction.md +14 -8
  34. package/guidelines/transportRule/transportRule.instruction.md +31 -1
  35. package/incrementalBuilder.proc.js +577 -411
  36. package/{index-w15mg3km.js → index-0dm25wvf.js} +1 -1
  37. package/{index-0gg15zwa.js → index-0s7w2085.js} +6 -6
  38. package/{index-hj6w4ka1.js → index-1p81ecbz.js} +1 -1
  39. package/{index-swwjakt0.js → index-275a4r3n.js} +11 -11
  40. package/{index-j6gc8n14.js → index-2jmvfa62.js} +11 -9
  41. package/{index-qd7xn2bk.js → index-2ny1e95c.js} +2 -2
  42. package/{index-exn38bzx.js → index-2yn3r67f.js} +116 -54
  43. package/{index-34792nh7.js → index-3txdtztz.js} +1 -1
  44. package/{index-28x1aszt.js → index-41a03gkj.js} +149 -53
  45. package/{index-2mf1aen9.js → index-4ss4gkv3.js} +2 -2
  46. package/{index-an76bdrv.js → index-612fdtbk.js} +1 -1
  47. package/{index-5radqwn2.js → index-67sd09ag.js} +12 -12
  48. package/{index-0hbtve0a.js → index-6dzjer7p.js} +32 -28
  49. package/{index-3ghdb7p5.js → index-71y6176j.js} +2777 -3676
  50. package/{index-xyn02k0w.js → index-78y75t0a.js} +662 -433
  51. package/index-7wf8snar.js +80 -0
  52. package/{index-skmtj8rm.js → index-8jtqfye2.js} +27 -10
  53. package/{index-2mrn1mrg.js → index-9f3reh2y.js} +1 -1
  54. package/{index-nmvhjn8c.js → index-9wh04mqy.js} +93 -82
  55. package/{index-xvk2a75m.js → index-a860mx0m.js} +3 -3
  56. package/{index-5zwr4n6k.js → index-baccvws5.js} +65 -8
  57. package/{index-yf9wc28h.js → index-bejy9zyc.js} +1 -1
  58. package/{index-bns3wcpc.js → index-by2tvsq6.js} +1 -1
  59. package/{index-r0a604h4.js → index-c669pbyb.js} +5 -4
  60. package/{index-x40bdsca.js → index-dadwp2aw.js} +33 -98
  61. package/{index-vm0dn0mt.js → index-dmcpetwe.js} +200 -138
  62. package/{index-43f4h4cm.js → index-ebn9kgea.js} +6 -6
  63. package/{index-hqv34wzq.js → index-gt8phqpt.js} +10 -10
  64. package/{index-yckz5t8b.js → index-h901f24n.js} +516 -434
  65. package/{index-j3v29pq7.js → index-j0wr4e32.js} +219 -175
  66. package/{index-gcx48get.js → index-j592zfqc.js} +2 -2
  67. package/{index-grxs6fts.js → index-j6jjmn2r.js} +57 -31
  68. package/{index-w8yasvpc.js → index-jek2re5k.js} +2136 -2175
  69. package/{index-ny2k80mv.js → index-jf4vk1s0.js} +9 -2
  70. package/{index-gxav1bjz.js → index-k6vwww45.js} +9 -9
  71. package/{index-99qvtff2.js → index-kfvjzk8r.js} +5 -5
  72. package/{index-j6eeh5d7.js → index-knpm8sdm.js} +5 -5
  73. package/{index-2r9ff9qm.js → index-nc3br31y.js} +2 -2
  74. package/{index-35j83zkd.js → index-p5zh7pmc.js} +2 -2
  75. package/{index-cmg5ngqa.js → index-p7beqww9.js} +2 -2
  76. package/{index-b4qq3rq0.js → index-rwgqba9p.js} +1 -1
  77. package/{index-rfzp4pqs.js → index-s885g0jj.js} +3 -3
  78. package/{index-9p260r4e.js → index-trffs83s.js} +538 -250
  79. package/{index-k92x3vne.js → index-v7ajmsh3.js} +1 -1
  80. package/index-w1zexzpx.js +127 -0
  81. package/{index-h7hehkw6.js → index-xczjdng6.js} +3 -1
  82. package/{index-39jz41jb.js → index-xs9a3ddt.js} +3 -3
  83. package/{index-rp4yf32g.js → index-xwwex8rf.js} +36 -29
  84. package/{index-ra9fvn7s.js → index-ybcb9wc8.js} +74 -38
  85. package/index-z92zm3wd.js +788 -0
  86. package/{index-j9790rhk.js → index-z96ks033.js} +1509 -1121
  87. package/index-zfnz878d.js +30 -0
  88. package/{index-2vgv7fs7.js → index-zmd9xxgd.js} +727 -693
  89. package/{index-ygdbn9jn.js → index-zyb0ebm4.js} +1 -1
  90. package/index.js +28 -24
  91. package/libExecutor-jc6f8hm6.js +10 -0
  92. package/{library.command-bmd7zc5m.js → library.command-nxvesvhb.js} +12 -5
  93. package/{localRegistry.command-y6en1599.js → localRegistry.command-xz62e4ng.js} +29 -24
  94. package/{module.command-7exfffqw.js → module.command-aaws9byg.js} +11 -7
  95. package/{package.command-adskw2rj.js → package.command-j7hv26p0.js} +14 -10
  96. package/package.json +8 -8
  97. package/{page.command-dw01272p.js → page.command-7yffs7n9.js} +8 -4
  98. package/{pipeline.command-0b1r3y5r.js → pipeline.command-7yk0zcng.js} +15 -9
  99. package/pkgExecutor-arxmvx4t.js +10 -0
  100. package/{primitive.command-byw6vc04.js → primitive.command-7a1pt715.js} +12 -8
  101. package/{projectTypecheck-kkrpq60a.js → projectTypecheck-f4qhbecd.js} +1 -1
  102. package/{prompter-qrwx1p17.js → prompter-qyggfhqd.js} +2 -2
  103. package/{quality.command-6rqnhzct.js → quality.command-c6mvrjh1.js} +25 -16
  104. package/{recipeScanner-4b69ybe0.js → recipeScanner-rrx69awy.js} +1 -1
  105. package/{repair.command-rw5zymak.js → repair.command-093adzt9.js} +12 -8
  106. package/{routeSourceValidator-4h947v7c.js → routeSourceValidator-8n6j1vn7.js} +4 -2
  107. package/{scalar.command-2dyp9nh9.js → scalar.command-2ex84spb.js} +10 -6
  108. package/skills/akan-debug/SKILL.md +8 -5
  109. package/skills/akan-err/SKILL.md +7 -0
  110. package/skills/akan-mcp/SKILL.md +19 -1
  111. package/skills/akan-scaffold/SKILL.md +1 -1
  112. package/skills/akan-validate/SKILL.md +3 -3
  113. package/{subspace.command-111ynwv1.js → subspace.command-4n4n4jpv.js} +32 -24
  114. package/templates/app/page/_layout.tsx +13 -0
  115. package/templates/app/page/styles.css.template +40 -0
  116. package/templates/appSample/page/_index.tsx +9 -9
  117. package/templates/appSample/page/_layout.tsx +1 -0
  118. package/templates/appSample/page/styles.css.template +40 -5
  119. package/templates/appSample/ui/Recipe/jellyButton.ts +1 -1
  120. package/templates/biomeForm.ts +1 -1
  121. package/templates/env/_env.server.type.ts +1 -1
  122. package/templates/facetIndex/index.ts +2 -37
  123. package/templates/lib/sig.ts +0 -4
  124. package/templates/lib/useClient.ts +1 -1
  125. package/templates/workspaceRoot/.devcontainer/devcontainer.json.template +1 -1
  126. package/templates/workspaceRoot/AGENTS.md.template +2 -1
  127. package/templates/workspaceRoot/README.ts +4 -2
  128. package/{tunnel.command-2gcpfbdj.js → tunnel.command-f7ep1qfa.js} +17 -13
  129. package/{typeChecker-s640r6c0.js → typeChecker-7jt6abrs.js} +1 -1
  130. package/typecheck.proc.js +3 -2
  131. package/{verify.command-djgs86ma.js → verify.command-zrkxnvct.js} +21 -17
  132. package/{workflow.command-n0k2mxr5.js → workflow.command-ks16jegk.js} +21 -14
  133. package/{workspace.command-fh1qwxfx.js → workspace.command-ahhfpaag.js} +60 -54
  134. package/CodeAgent-x2p3a3e0.js +0 -11
  135. package/TunnelShare-c4xsfzg5.js +0 -15
  136. package/agent.command-9et2e27p.js +0 -52
  137. package/cloud.script-xze4zh7n.js +0 -31
  138. package/context.command-rk1dwrg4.js +0 -57
  139. package/context.runner-83ky5m1b.js +0 -30
  140. /package/templates/{appSample → app}/public/fonts/Pretendard-Bold.woff2 +0 -0
  141. /package/templates/{appSample → app}/public/fonts/Pretendard-Medium.woff2 +0 -0
  142. /package/templates/{appSample → app}/public/fonts/Pretendard-Regular.woff2 +0 -0
  143. /package/templates/{appSample → app}/public/fonts/Pretendard-SemiBold.woff2 +0 -0
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  akanCodePaths2
4
- } from "./index-35j83zkd.js";
4
+ } from "./index-p5zh7pmc.js";
5
5
 
6
6
  // pkgs/@akanjs/devkit/codeAgent/agent/WorkspaceTrust.ts
7
7
  import { createHash } from "crypto";
@@ -1,16 +1,16 @@
1
1
  // @bun
2
2
  import {
3
- akanMcpInstallTargets
4
- } from "./index-yckz5t8b.js";
3
+ script
4
+ } from "./index-2yn3r67f.js";
5
5
  import {
6
6
  jsonText
7
- } from "./index-2vgv7fs7.js";
7
+ } from "./index-zmd9xxgd.js";
8
8
  import {
9
- script
10
- } from "./index-exn38bzx.js";
9
+ akanMcpInstallTargets
10
+ } from "./index-h901f24n.js";
11
11
  import {
12
12
  ContextRunner2
13
- } from "./index-j3v29pq7.js";
13
+ } from "./index-j0wr4e32.js";
14
14
 
15
15
  // pkgs/@akanjs/cli/context/context.script.ts
16
16
  import { Logger } from "akanjs/common";
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- // pkgs/@akanjs/devkit/recipeScanner.ts
2
+ // pkgs/@akanjs/devkit/context/recipeScanner.ts
3
3
  import { readdir } from "fs/promises";
4
4
  import ts from "typescript";
5
5
  var collectRecipeSources2 = async (uiDirPath, importFrom, basename = "Recipe") => {
@@ -2,22 +2,22 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-exn38bzx.js";
5
+ } from "./index-2yn3r67f.js";
6
6
  import {
7
7
  FileSys2
8
- } from "./index-bns3wcpc.js";
8
+ } from "./index-by2tvsq6.js";
9
9
  import {
10
- PkgExecutor
11
- } from "./index-3ghdb7p5.js";
12
- import {
13
- TypeScriptDependencyScanner2
14
- } from "./index-qd7xn2bk.js";
10
+ PkgExecutor2
11
+ } from "./index-w1zexzpx.js";
15
12
  import {
16
13
  FrameworkGraph
17
- } from "./index-cmg5ngqa.js";
14
+ } from "./index-p7beqww9.js";
18
15
  import {
19
16
  MaintainabilityBaseline
20
- } from "./index-5zwr4n6k.js";
17
+ } from "./index-baccvws5.js";
18
+ import {
19
+ TypeScriptDependencyScanner2
20
+ } from "./index-2ny1e95c.js";
21
21
  import {
22
22
  assertPackageName
23
23
  } from "./index-va90m8nd.js";
@@ -25,7 +25,7 @@ import {
25
25
  // pkgs/@akanjs/cli/package/package.runner.ts
26
26
  import path2 from "path";
27
27
 
28
- // pkgs/@akanjs/devkit/packageExportsMap.ts
28
+ // pkgs/@akanjs/devkit/workspace/packageExportsMap.ts
29
29
  import { statSync } from "fs";
30
30
  import path from "path";
31
31
 
@@ -373,7 +373,7 @@ ${problems.join(`
373
373
  return { file: FrameworkGraph.architectureFile, changed: next !== current };
374
374
  }
375
375
  async verifyAkanPublishPackages(workspace) {
376
- const pkgs = PackageRunner.publishableAkanPackages.map((pkgName) => PkgExecutor.from(workspace, pkgName));
376
+ const pkgs = PackageRunner.publishableAkanPackages.map((pkgName) => PkgExecutor2.from(workspace, pkgName));
377
377
  const peerExportsMaps = new Map;
378
378
  for (const pkg of pkgs) {
379
379
  if (!await Bun.file(`${pkg.dist.cwdPath}/package.json`).exists())
@@ -2,13 +2,15 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-exn38bzx.js";
5
+ } from "./index-2yn3r67f.js";
6
6
  import {
7
- LibSource,
8
- formatLibStatuses,
9
7
  CommandExecutionError,
10
- LibExecutor
11
- } from "./index-3ghdb7p5.js";
8
+ LibSource,
9
+ formatLibStatuses
10
+ } from "./index-71y6176j.js";
11
+ import {
12
+ LibExecutor2
13
+ } from "./index-zfnz878d.js";
12
14
  import {
13
15
  assertPlainName
14
16
  } from "./index-va90m8nd.js";
@@ -16,7 +18,7 @@ import {
16
18
  // pkgs/@akanjs/cli/library/library.script.ts
17
19
  import { Logger } from "akanjs/common";
18
20
 
19
- // pkgs/@akanjs/devkit/semver.ts
21
+ // pkgs/@akanjs/devkit/util/semver.ts
20
22
  var stripRangeOperator = (version) => version.replace(/^[\s^~>=<v]+/, "").trim();
21
23
  var parseVersion = (version) => version.replace(/^[^\d]*/, "").split(/[.-]/).map((part) => Number.parseInt(part, 10)).map((part) => Number.isFinite(part) ? part : 0);
22
24
  var compareNumeric = (a, b) => {
@@ -46,7 +48,7 @@ class LibraryRunner extends runner("library") {
46
48
  async createLibrary(libName, workspace) {
47
49
  await workspace.mkdir(`libs/${libName}`);
48
50
  await workspace.applyTemplate({ basePath: `libs/${libName}`, template: "libRoot", dict: { libName } });
49
- return LibExecutor.from(workspace, libName);
51
+ return LibExecutor2.from(workspace, libName);
50
52
  }
51
53
  async removeLibrary(lib) {
52
54
  await lib.workspace.removeDir(`libs/${lib.name}`);
@@ -102,7 +104,7 @@ class LibraryRunner extends runner("library") {
102
104
  const testingEnv = `libs/${libName}/env/env.server.testing.ts`;
103
105
  if (!await workspace.exists(testingEnv))
104
106
  await workspace.cp(`libs/${libName}/env/env.server.example.ts`, testingEnv);
105
- const lib = LibExecutor.from(workspace, libName);
107
+ const lib = LibExecutor2.from(workspace, libName);
106
108
  const stamp = await new LibSource(lib).write(source);
107
109
  if (await workspace.hasChanges())
108
110
  await workspace.commit(`Install ${libName} library from ${stamp.origin}`);
@@ -110,7 +112,7 @@ class LibraryRunner extends runner("library") {
110
112
  }
111
113
  async libraryStatuses(workspace) {
112
114
  const libNames = await workspace.getLibs();
113
- return await Promise.all(libNames.map((libName) => new LibSource(LibExecutor.from(workspace, libName)).status()));
115
+ return await Promise.all(libNames.map((libName) => new LibSource(LibExecutor2.from(workspace, libName)).status()));
114
116
  }
115
117
  async mergeLibraryDependencies(lib) {
116
118
  const [libPackageJson, rootPackageJson] = await Promise.all([lib.getPackageJson(), lib.workspace.getPackageJson()]);
@@ -1,9 +1,9 @@
1
1
  // @bun
2
2
  import {
3
3
  FileSys2
4
- } from "./index-bns3wcpc.js";
4
+ } from "./index-by2tvsq6.js";
5
5
 
6
- // pkgs/@akanjs/devkit/dependencyScanner.ts
6
+ // pkgs/@akanjs/devkit/workspace/dependencyScanner.ts
7
7
  import { builtinModules } from "module";
8
8
  import * as path from "path";
9
9
  import ignore from "ignore";
@@ -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-71y6176j.js";
5
9
  import {
6
10
  getDirname2,
7
11
  FileSys2
8
- } from "./index-bns3wcpc.js";
12
+ } from "./index-by2tvsq6.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-z92zm3wd.js";
16
+ import {
17
+ LibExecutor2
18
+ } from "./index-zfnz878d.js";
19
+ import {
20
+ PkgExecutor2
21
+ } from "./index-w1zexzpx.js";
22
+ import {
23
+ ModuleExecutor,
24
+ ErrorReport
25
+ } from "./index-7wf8snar.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 };
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-exn38bzx.js";
5
+ } from "./index-2yn3r67f.js";
6
6
 
7
7
  // pkgs/@akanjs/cli/page/page.runner.ts
8
8
  class PageRunner extends runner("page") {