@akanjs/cli 3.1.0-rc.8 → 3.1.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 (92) hide show
  1. package/.build-stamp +1 -1
  2. package/{CodeAgent-rkjyxgec.js → CodeAgent-c53dm40p.js} +2 -2
  3. package/{CodeAgentRpcHost-p7h6n2hp.js → CodeAgentRpcHost-9g27hmer.js} +1 -1
  4. package/{CodeTui-h7pyj6xa.js → CodeTui-xz9jtrn3.js} +47 -4
  5. package/README.ko.md +1 -1
  6. package/README.md +1 -1
  7. package/TunnelShare-59zd4j8n.js +14 -0
  8. package/{agent.command-3qxf4xcj.js → agent.command-qawf7z4s.js} +5 -5
  9. package/akanCode.js +7 -5
  10. package/{application.command-m1kcd7jf.js → application.command-jqrgqk6j.js} +35 -9
  11. package/{applicationBuildRunner-dj0xkrep.js → applicationBuildRunner-grgrey5c.js} +23 -8
  12. package/buildBatch.proc.js +9 -9
  13. package/{cloud.command-3jzym8q7.js → cloud.command-p9067ssj.js} +13 -13
  14. package/cloud.script-f0r4ce7j.js +24 -0
  15. package/{code.command-0ad6gw2a.js → code.command-t6j55sbk.js} +25 -12
  16. package/commandManifest.json +1 -1
  17. package/{context.command-0qx447mb.js → context.command-eqbzbgth.js} +16 -16
  18. package/context.runner-1cs88ags.js +25 -0
  19. package/{guideline.command-cv5bmrx2.js → guideline.command-w905q73w.js} +2 -2
  20. package/guidelines/agentRule/agentRule.instruction.md +25 -10
  21. package/guidelines/conventions/conventions.instruction.md +71 -24
  22. package/guidelines/fieldRule/fieldRule.instruction.md +17 -0
  23. package/guidelines/mcpRule/mcpRule.instruction.md +93 -48
  24. package/guidelines/modelDocument/modelDocument.instruction.md +2 -1
  25. package/guidelines/modelStore/modelStore.instruction.md +7 -0
  26. package/guidelines/pageRule/pageRule.instruction.md +55 -8
  27. package/guidelines/queryRule/queryRule.instruction.md +24 -10
  28. package/guidelines/runtimeRule/runtimeRule.instruction.md +12 -4
  29. package/guidelines/ssrRule/ssrRule.instruction.md +9 -6
  30. package/guidelines/transportRule/transportRule.instruction.md +36 -5
  31. package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +5 -3
  32. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +28 -8
  33. package/incrementalBuilder.proc.js +3 -3
  34. package/{index-j4mkhz93.js → index-0dd6z4b9.js} +3 -3
  35. package/{index-h47cf1gg.js → index-1de5f0qq.js} +7 -7
  36. package/{index-6xn2n442.js → index-1enc9rga.js} +4 -4
  37. package/index-25ks6x4k.js +643 -0
  38. package/{index-wa5jbxj1.js → index-2mrn1mrg.js} +1 -0
  39. package/{index-qwa5k1j8.js → index-3aynkpf8.js} +1 -1
  40. package/{index-vk0pa0mn.js → index-3hvmytbs.js} +2 -1
  41. package/{index-w44cy4vs.js → index-45c0mxb6.js} +2 -2
  42. package/{index-fyq1z6kt.js → index-48n4yhm4.js} +3 -3
  43. package/{index-192ha4xh.js → index-64pjry21.js} +1 -1
  44. package/{index-5edzv8fn.js → index-aqwdjn4x.js} +2 -2
  45. package/{index-d2242ksy.js → index-at7bz0xq.js} +3 -0
  46. package/{index-9z426msb.js → index-avjqbtkj.js} +7 -6
  47. package/{index-20bxxyvn.js → index-bs9yr4we.js} +40 -2
  48. package/{index-d72hfmdm.js → index-cgexcnwd.js} +8 -8
  49. package/{index-1xj2t7cb.js → index-dkfadmrx.js} +7 -7
  50. package/{index-35hc95h5.js → index-eabfsarf.js} +1 -1
  51. package/{index-pydbnfez.js → index-er62k6w3.js} +35 -9
  52. package/{index-1p98exm2.js → index-f2gfq0yh.js} +2 -2
  53. package/{index-jw1zm273.js → index-fbw3kmt5.js} +54 -10
  54. package/{index-4mhy6qme.js → index-fnqj2d2w.js} +4 -4
  55. package/{index-awbdfcf2.js → index-hqh4mpgt.js} +4 -4
  56. package/{index-fmzcs8v6.js → index-j4dzazmw.js} +4 -4
  57. package/{index-va06nr10.js → index-n8dsax1f.js} +64 -19
  58. package/{index-g1mbppa9.js → index-nr8m4j21.js} +5 -5
  59. package/{index-86jt2a0e.js → index-qh73jnyb.js} +1 -1
  60. package/{index-8fp3b47h.js → index-vtj332gj.js} +281 -46
  61. package/{index-tamvyvj3.js → index-wt7m1hfc.js} +3 -3
  62. package/{index-cpb3nvma.js → index-yfy3t4kw.js} +2 -2
  63. package/{index-trpasv9q.js → index-yyxy7aff.js} +1 -1
  64. package/{index-d47ypebv.js → index-z5cxrbvv.js} +75 -19
  65. package/index.js +40 -22
  66. package/{library.command-erp2f56n.js → library.command-z1v7zepj.js} +3 -3
  67. package/{localRegistry.command-xxpqgxjw.js → localRegistry.command-48n23bjy.js} +12 -12
  68. package/{module.command-gs2r615e.js → module.command-rv307dk7.js} +5 -5
  69. package/{package.command-7343f74r.js → package.command-7xkzc8m1.js} +3 -3
  70. package/package.json +22 -22
  71. package/{page.command-4h4a8pnh.js → page.command-34hpdt7v.js} +3 -3
  72. package/{pipeline.command-a2nrk26m.js → pipeline.command-ckvhrpyg.js} +2 -2
  73. package/{primitive.command-w6t0asqz.js → primitive.command-em0twr5a.js} +6 -6
  74. package/{projectTypecheck-f534enqj.js → projectTypecheck-fy6hn05y.js} +1 -1
  75. package/{quality.command-77x7vbbx.js → quality.command-c6p2819k.js} +2 -2
  76. package/{repair.command-y6sstev7.js → repair.command-j6czdgrv.js} +5 -5
  77. package/{routeSourceValidator-7ycnfz0e.js → routeSourceValidator-6jd0q6r6.js} +47 -14
  78. package/{scalar.command-20b8cy0k.js → scalar.command-17e20sj2.js} +4 -4
  79. package/skills/akan-code/SKILL.md +4 -0
  80. package/skills/akan-store/SKILL.md +4 -2
  81. package/{subspace.command-92xkc0s0.js → subspace.command-n3j7vv0w.js} +8 -17
  82. package/templates/migration/__migrationId__.ts +23 -0
  83. package/templates/server.ts +8 -1
  84. package/templates/workspaceRoot/.gitignore.template +1 -1
  85. package/templates/workspaceRoot/biome.json.template +1 -1
  86. package/{tunnel.command-2kw8vt9g.js → tunnel.command-cm578f4s.js} +7 -7
  87. package/{workflow.command-2djwmpqf.js → workflow.command-h9vkr6jb.js} +10 -10
  88. package/{workspace.command-5se6spqb.js → workspace.command-tp8ysvjs.js} +30 -28
  89. package/TunnelShare-661cxz5e.js +0 -14
  90. package/cloud.script-r4nskbc6.js +0 -24
  91. package/context.runner-1vsjztjg.js +0 -25
  92. package/index-665zp9rs.js +0 -271
@@ -19,11 +19,11 @@ import {
19
19
  CsrDevPaths,
20
20
  PagesEntrySourceGenerator,
21
21
  PagesBundleBuilder
22
- } from "./index-192ha4xh.js";
22
+ } from "./index-64pjry21.js";
23
23
  import {
24
24
  AsyncDefaultExportDetector,
25
25
  resolveSsrPageEntriesForApp
26
- } from "./index-va06nr10.js";
26
+ } from "./index-n8dsax1f.js";
27
27
 
28
28
  // pkgs/@akanjs/devkit/frontendBuild/autoImportSync.ts
29
29
  import { readdir, readFile, stat } from "fs/promises";
@@ -5,15 +5,15 @@ import {
5
5
  CloudApi,
6
6
  CloudUpdates,
7
7
  PipelineSecrets
8
- } from "./index-cpb3nvma.js";
8
+ } from "./index-yfy3t4kw.js";
9
9
  import {
10
10
  WorkspaceExecutor,
11
11
  AppExecutor
12
- } from "./index-va06nr10.js";
12
+ } from "./index-n8dsax1f.js";
13
13
  import {
14
14
  runner,
15
15
  assertPromptable
16
- } from "./index-jw1zm273.js";
16
+ } from "./index-fbw3kmt5.js";
17
17
  import {
18
18
  SubspaceConfig
19
19
  } from "./index-4pf8g7ff.js";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  AsyncDefaultExportDetector,
4
4
  resolveSsrPageEntriesForApp
5
- } from "./index-va06nr10.js";
5
+ } from "./index-n8dsax1f.js";
6
6
  import {
7
7
  FileSys2
8
8
  } from "./index-52w0fvh8.js";
@@ -10,7 +10,7 @@ import {
10
10
  isScannedRootEntry,
11
11
  AppExecutor,
12
12
  LibExecutor
13
- } from "./index-va06nr10.js";
13
+ } from "./index-n8dsax1f.js";
14
14
  import {
15
15
  FileSys2
16
16
  } from "./index-52w0fvh8.js";
@@ -23,7 +23,7 @@ import {
23
23
  workflowPathsForPlan,
24
24
  workflowRunArtifactPath,
25
25
  workflowSyncDir
26
- } from "./index-trpasv9q.js";
26
+ } from "./index-yyxy7aff.js";
27
27
 
28
28
  // pkgs/@akanjs/devkit/akanContext.ts
29
29
  import { readdir } from "fs/promises";
@@ -77,6 +77,9 @@ class CodeAgentRpcHost2 {
77
77
  case "set_model":
78
78
  await this.#agent.setModel({ provider: command.provider, id: command.modelId });
79
79
  return await this.#agent.state();
80
+ case "set_auto_compact":
81
+ this.#agent.setAutoCompactAt(command.percent);
82
+ return await this.#agent.state();
80
83
  case "get_state":
81
84
  return await this.#agent.state(command.sinceSeq === undefined ? {} : { sinceSeq: command.sinceSeq });
82
85
  case "shutdown":
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  resolveSsrPageEntriesForApp
4
- } from "./index-va06nr10.js";
4
+ } from "./index-n8dsax1f.js";
5
5
  import {
6
6
  computeRouteSeedIndex,
7
7
  saveRouteSeedIndex,
@@ -9,7 +9,7 @@ import {
9
9
  ClientEntriesBundler,
10
10
  VENDOR_SPECIFIERS,
11
11
  RouteClientBuilder
12
- } from "./index-w44cy4vs.js";
12
+ } from "./index-45c0mxb6.js";
13
13
  import {
14
14
  SOURCE_EXTS
15
15
  } from "./index-5nd1wtkv.js";
@@ -19,7 +19,7 @@ import {
19
19
  createTsconfigPackageResolver,
20
20
  rewriteBarrelImports,
21
21
  PagesBundleBuilder
22
- } from "./index-192ha4xh.js";
22
+ } from "./index-64pjry21.js";
23
23
  import {
24
24
  CssBlockParser
25
25
  } from "./index-62md4dwy.js";
@@ -137,10 +137,10 @@ import { compile } from "tailwindcss";
137
137
 
138
138
  // pkgs/@akanjs/devkit/frontendBuild/cssCandidateCache.ts
139
139
  import { stat } from "fs/promises";
140
- var CANDIDATE_RE = /-?(?:[\w@]|\[[^\]\s]+\])[\w:/.-]*(?:(?:\[[^\]\s]+\]|\((?:[a-z-]+:)?--[^)\s]+\))[\w:/.-]*)*/g;
140
+ var CANDIDATE_RE = /-?(?:[\w@]|\[(?:[^[\]\s]|\[[^[\]\s]+\])+\])[\w:/.-]*(?:(?:\[(?:[^[\]\s]|\[[^[\]\s]+\])+\]|\((?:[a-z-]+:)?--[^)\s]+\))[\w:/.-]*)*/g;
141
141
 
142
142
  class CssCandidateCache {
143
- static #version = 4;
143
+ static #version = 5;
144
144
  #path;
145
145
  #entries = new Map;
146
146
  #dirty = false;
@@ -1240,7 +1240,8 @@ class FontPruner {
1240
1240
  { dir: path5.join(this.#artifactRoot, "client"), label: ".akan/artifact/client", needles: bundled },
1241
1241
  { dir: path5.join(this.#artifactRoot, "client-ssr"), label: ".akan/artifact/client-ssr", needles: bundled },
1242
1242
  { dir: path5.join(this.#artifactRoot, "server"), label: ".akan/artifact/server", needles: bundled },
1243
- { dir: path5.join(this.#app.dist.cwdPath, "csr"), label: "csr", needles: bundled }
1243
+ { dir: path5.join(this.#app.dist.cwdPath, "csr"), label: "csr", needles: bundled },
1244
+ { dir: path5.join(this.#app.dist.cwdPath, "mcp-apps"), label: "mcp-apps", needles: bundled }
1244
1245
  ];
1245
1246
  for (const root of roots) {
1246
1247
  const pending = root.needles.filter((candidate) => !referrers.has(candidate.rel));
@@ -3,6 +3,44 @@ import {
3
3
  ConfigLock
4
4
  } from "./index-bqbf654f.js";
5
5
 
6
+ // pkgs/@akanjs/devkit/codeAgent/agent/AkanCodeCompaction.ts
7
+ class AkanCodeCompaction2 {
8
+ static reserveFloor = 32768;
9
+ static steps = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100];
10
+ static isStep(percent) {
11
+ return AkanCodeCompaction2.steps.some((step) => step === percent);
12
+ }
13
+ static normalize(percent) {
14
+ if (percent === undefined)
15
+ return;
16
+ if (!AkanCodeCompaction2.isStep(percent))
17
+ throw new Error(`Autocompact takes a percent in steps of 10: ${AkanCodeCompaction2.steps.join(", ")}.`);
18
+ return percent === 100 ? undefined : percent;
19
+ }
20
+ static thresholdOf(contextWindow, percent) {
21
+ const share = percent ? Math.floor(contextWindow * percent / 100) : contextWindow;
22
+ return Math.min(share, contextWindow - AkanCodeCompaction2.reserveFloor);
23
+ }
24
+ static apply(settings, model, percent) {
25
+ const threshold = AkanCodeCompaction2.thresholdOf(model.contextWindow, percent);
26
+ settings.applyOverrides({
27
+ compaction: {
28
+ modelOverrides: { [`${model.provider}/${model.id}`]: { reserveTokens: model.contextWindow - threshold } }
29
+ }
30
+ });
31
+ }
32
+ static problemOf(model, percent, keepRecentTokens) {
33
+ const name = `${model.provider}/${model.id}`;
34
+ if (model.contextWindow <= 0)
35
+ return `${name} declares no context window, so it has no share to compact at.`;
36
+ const threshold = AkanCodeCompaction2.thresholdOf(model.contextWindow, percent);
37
+ if (threshold >= keepRecentTokens)
38
+ return;
39
+ const k = (tokens) => `${Math.round(tokens / 1000)}k`;
40
+ return `Compacting at ${percent}% of the ${k(model.contextWindow)} window of ${name} starts at ${k(threshold)}, under the ${k(keepRecentTokens)} of recent turns every compaction keeps, so every turn would compact again.`;
41
+ }
42
+ }
43
+
6
44
  // pkgs/@akanjs/devkit/codeAgent/agent/akanCodePaths.ts
7
45
  import { existsSync } from "fs";
8
46
  import { homedir } from "os";
@@ -141,7 +179,7 @@ class SubagentPool2 {
141
179
  }
142
180
  }
143
181
  async#run(id, kind, prompt, signal) {
144
- const { CodeAgent } = await import("./CodeAgent-rkjyxgec.js");
182
+ const { CodeAgent } = await import("./CodeAgent-c53dm40p.js");
145
183
  const budget = this.#options.parent.tools.subagent;
146
184
  const child = SubagentPool2.childOf(this.#options.parent, kind);
147
185
  const agent = await CodeAgent.create({
@@ -697,4 +735,4 @@ ${stored.refreshToken}`;
697
735
  }
698
736
  }
699
737
 
700
- export { SubagentPool2, akanCodePaths2, McpServerConfig, McpTokenStore, McpSignIn };
738
+ export { SubagentPool2, akanCodePaths2, McpServerConfig, McpTokenStore, McpSignIn, AkanCodeCompaction2 };
@@ -1,13 +1,13 @@
1
1
  // @bun
2
2
  import {
3
3
  AppExecutor
4
- } from "./index-va06nr10.js";
4
+ } from "./index-n8dsax1f.js";
5
5
  import {
6
6
  jsonText,
7
7
  createWorkflowBaselineSummary,
8
8
  buildAkanModuleContextIndex,
9
9
  toolingRolloutGate
10
- } from "./index-trpasv9q.js";
10
+ } from "./index-yyxy7aff.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-5edzv8fn.js";
20
+ } from "./index-aqwdjn4x.js";
21
21
  import {
22
22
  runner
23
- } from "./index-jw1zm273.js";
23
+ } from "./index-fbw3kmt5.js";
24
24
  import {
25
25
  isPlaceholderAppId
26
- } from "./index-vk0pa0mn.js";
26
+ } from "./index-3hvmytbs.js";
27
27
  import {
28
28
  getMobileTargets,
29
29
  appIdsOf
30
30
  } from "./index-m9jj544v.js";
31
31
  import {
32
32
  NativeApp
33
- } from "./index-g1mbppa9.js";
33
+ } from "./index-nr8m4j21.js";
34
34
  import {
35
35
  Prompter2
36
36
  } from "./index-zzvvc845.js";
37
37
  import {
38
38
  RepairRunner
39
- } from "./index-j4mkhz93.js";
39
+ } from "./index-0dd6z4b9.js";
40
40
  import {
41
41
  WorkflowRunner
42
- } from "./index-1xj2t7cb.js";
42
+ } from "./index-dkfadmrx.js";
43
43
 
44
44
  // pkgs/@akanjs/devkit/akanMcpContract.ts
45
45
  import path from "path";
@@ -22,26 +22,26 @@ import {
22
22
  renderWorkflowApply,
23
23
  renderWorkflowValidation,
24
24
  renderWorkflowRunArtifact
25
- } from "./index-trpasv9q.js";
25
+ } from "./index-yyxy7aff.js";
26
26
  import {
27
27
  AkanContextAnalyzer
28
- } from "./index-5edzv8fn.js";
28
+ } from "./index-aqwdjn4x.js";
29
29
  import {
30
30
  CommandContainer,
31
31
  runner
32
- } from "./index-jw1zm273.js";
32
+ } from "./index-fbw3kmt5.js";
33
33
  import {
34
34
  ModuleScript
35
- } from "./index-fmzcs8v6.js";
35
+ } from "./index-j4dzazmw.js";
36
36
  import {
37
37
  PrimitiveScript
38
- } from "./index-awbdfcf2.js";
38
+ } from "./index-hqh4mpgt.js";
39
39
  import {
40
40
  spawnShell
41
- } from "./index-j4mkhz93.js";
41
+ } from "./index-0dd6z4b9.js";
42
42
  import {
43
43
  ScalarScript
44
- } from "./index-1p98exm2.js";
44
+ } from "./index-f2gfq0yh.js";
45
45
 
46
46
  // pkgs/@akanjs/cli/workflow/workflow.runner.ts
47
47
  import { mkdir, readFile, writeFile } from "fs/promises";
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  AppInfo
4
- } from "./index-va06nr10.js";
4
+ } from "./index-n8dsax1f.js";
5
5
 
6
6
  // pkgs/@akanjs/devkit/slicePlanner.ts
7
7
  class SlicePlanner {
@@ -2,12 +2,13 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-jw1zm273.js";
5
+ } from "./index-fbw3kmt5.js";
6
6
  import {
7
7
  LibSource,
8
8
  formatLibStatuses,
9
+ CommandExecutionError,
9
10
  LibExecutor
10
- } from "./index-va06nr10.js";
11
+ } from "./index-n8dsax1f.js";
11
12
 
12
13
  // pkgs/@akanjs/cli/library/library.script.ts
13
14
  import { Logger } from "akanjs/common";
@@ -37,6 +38,8 @@ var compareSemver = (a, b) => {
37
38
  // pkgs/@akanjs/cli/library/library.runner.ts
38
39
  class LibraryRunner extends runner("library") {
39
40
  static libraryRepository = "https://github.com/akan-team/akanjs.git";
41
+ static #cloneDir = "node_modules/.akan/akanjs";
42
+ #clones = new Map;
40
43
  async createLibrary(libName, workspace) {
41
44
  await workspace.mkdir(`libs/${libName}`);
42
45
  await workspace.applyTemplate({ basePath: `libs/${libName}`, template: "libRoot", dict: { libName } });
@@ -59,14 +62,37 @@ class LibraryRunner extends runner("library") {
59
62
  const { version } = await workspace.readJson(manifestPath);
60
63
  return version ?? "unknown";
61
64
  }
65
+ async#hasTag(workspace, tag) {
66
+ try {
67
+ await workspace.spawn("git", ["ls-remote", "--exit-code", LibraryRunner.libraryRepository, `refs/tags/${tag}`]);
68
+ return true;
69
+ } catch (error) {
70
+ if (error instanceof CommandExecutionError && error.code === 2)
71
+ return false;
72
+ throw error;
73
+ }
74
+ }
75
+ async#cloneRepository(workspace) {
76
+ const repository = LibraryRunner.libraryRepository;
77
+ const version = await this.#installedAkanVersion(workspace);
78
+ const tag = version === "unknown" ? null : `v${version}`;
79
+ const branch = tag && await this.#hasTag(workspace, tag) ? ["--branch", tag] : [];
80
+ if (!branch.length) {
81
+ const reason = tag ? `akanjs ${version} has no ${tag} tag` : "akanjs is not installed in this workspace";
82
+ workspace.logger.warn(`${reason}; installing libraries from the default branch of ${repository}, which may expect a newer akanjs`);
83
+ }
84
+ if (await workspace.exists(LibraryRunner.#cloneDir))
85
+ await workspace.removeDir(LibraryRunner.#cloneDir);
86
+ await workspace.spawn("git", ["clone", "--depth", "1", ...branch, repository, LibraryRunner.#cloneDir]);
87
+ const sha = await workspace.spawn("git", ["-C", LibraryRunner.#cloneDir, "rev-parse", "HEAD"]);
88
+ return { origin: repository, sha: sha.trim().slice(0, 12) };
89
+ }
62
90
  async#copyLibraryFromRepository(workspace, libName) {
63
- await workspace.mkdir("node_modules/.akan");
64
- if (await workspace.exists("node_modules/.akan/akanjs"))
65
- await workspace.removeDir("node_modules/.akan/akanjs");
66
- await workspace.exec(`cd node_modules/.akan && git clone ${LibraryRunner.libraryRepository}`);
67
- await workspace.cp(`node_modules/.akan/akanjs/libs/${libName}`, `libs/${libName}`);
68
- const sha = await workspace.spawn("git", ["-C", "node_modules/.akan/akanjs", "rev-parse", "HEAD"]);
69
- return { origin: LibraryRunner.libraryRepository, sha: sha.trim().slice(0, 12) };
91
+ const cloned = this.#clones.get(workspace.workspaceRoot);
92
+ const source = cloned && await workspace.exists(LibraryRunner.#cloneDir) ? cloned : await this.#cloneRepository(workspace);
93
+ this.#clones.set(workspace.workspaceRoot, source);
94
+ await workspace.cp(`${LibraryRunner.#cloneDir}/libs/${libName}`, `libs/${libName}`);
95
+ return source;
70
96
  }
71
97
  async installLibrary(workspace, libName) {
72
98
  const source = await this.#copyInstalledLibrary(workspace, libName) ?? await this.#copyLibraryFromRepository(workspace, libName);
@@ -2,12 +2,12 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-jw1zm273.js";
5
+ } from "./index-fbw3kmt5.js";
6
6
  import {
7
7
  generatedFilesForSync,
8
8
  createPassedPrimitiveReport,
9
9
  scalarChangedFiles
10
- } from "./index-trpasv9q.js";
10
+ } from "./index-yyxy7aff.js";
11
11
  import {
12
12
  pluralizeName
13
13
  } from "./index-nz8prx9g.js";
@@ -10,7 +10,7 @@ import {
10
10
  LibExecutor,
11
11
  PkgExecutor,
12
12
  ModuleExecutor
13
- } from "./index-va06nr10.js";
13
+ } from "./index-n8dsax1f.js";
14
14
 
15
15
  // pkgs/@akanjs/devkit/commandDecorators/camelToKebabCase.ts
16
16
  var camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
@@ -289,8 +289,9 @@ var formatCommandHelp = (command, key) => {
289
289
  const optName = `${flag}--${kebabName}${negation}`;
290
290
  const optDesc = opt.desc ?? "";
291
291
  const defaultVal = opt.default !== undefined ? chalk.gray(` [default: ${String(opt.default)}]`) : "";
292
+ const repeatable = opt.multiple ? chalk.gray(" (repeatable)") : "";
292
293
  const choices = opt.enum ? chalk.gray(typeof opt.enum === "function" ? " ([dynamic choices])" : ` (${opt.enum.map(formatChoice).join(", ")})`) : "";
293
- lines.push(` ${chalk.green(optName)} ${chalk.gray(optDesc)}${defaultVal}${choices}`);
294
+ lines.push(` ${chalk.green(optName)} ${chalk.gray(optDesc)}${defaultVal}${choices}${repeatable}`);
294
295
  }
295
296
  lines.push("");
296
297
  }
@@ -301,6 +302,10 @@ var formatCommandHelp = (command, key) => {
301
302
  // pkgs/@akanjs/devkit/commandDecorators/command.ts
302
303
  var loggedCliErrorObjects = new WeakSet;
303
304
  var loggedCliErrorMessages = new Set;
305
+ var markCliErrorPrinted = (error) => {
306
+ if (typeof error === "object" && error !== null)
307
+ loggedCliErrorObjects.add(error);
308
+ };
304
309
  var formatCliError = (error) => {
305
310
  if (error instanceof Error)
306
311
  return error.message || error.name;
@@ -341,7 +346,12 @@ var handleOption = (programCommand, argMeta) => {
341
346
  } = argMeta.argsOption;
342
347
  const kebabName = camelToKebabCase(argMeta.name);
343
348
  const choices = enumChoices && typeof enumChoices !== "function" ? normalizeEnumChoices(enumChoices) : null;
344
- 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);
345
355
  if (type === "boolean" && argMeta.argsOption.default === true)
346
356
  programCommand.option(`--no-${kebabName}`, `turn off --${kebabName}`);
347
357
  return programCommand;
@@ -359,6 +369,17 @@ var convertArgValue = (value, type) => {
359
369
  else
360
370
  return value === true || value === "true";
361
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
+ };
362
383
  var normalizeEnumChoices = (enumChoices) => enumChoices.map((choice) => typeof choice === "object" ? { value: choice.value, name: choice.label } : { value: choice, name: choice.toString() });
363
384
  var prompts = async () => await import("@inquirer/prompts");
364
385
  var select = (config, context) => prompts().then((m) => m.select(config, context));
@@ -384,8 +405,14 @@ var inputMessageOf = ({ name, argsOption: { desc, example, ask } }) => ask ? `${
384
405
  var getOptionValue = async (argMeta, opt, context) => {
385
406
  const {
386
407
  name,
387
- argsOption: { enum: enumChoices, default: defaultValue, type, desc, nullable, ask }
408
+ argsOption: { enum: enumChoices, default: defaultValue, type, desc, nullable, ask, multiple }
388
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
+ }
389
416
  if (opt[argMeta.name] !== undefined) {
390
417
  assertEnumChoice(argMeta, opt[argMeta.name]);
391
418
  return convertArgValue(opt[argMeta.name], type ?? "string");
@@ -574,6 +601,7 @@ var getInternalArgumentValue = async (argMeta, value, workspace) => {
574
601
  };
575
602
  var runCommands = async (...commands) => {
576
603
  let failureExitCode = 1;
604
+ let reportFailure = async (_error) => {};
577
605
  process.on("unhandledRejection", (error) => {
578
606
  printCliError(error);
579
607
  process.exit(ExitCodeError.codeOf(error) ?? failureExitCode);
@@ -603,7 +631,7 @@ var runCommands = async (...commands) => {
603
631
  if (installedAkanPackageJson && installedAkanPackageJson.version !== process.env.AKAN_VERSION) {
604
632
  Logger.rawLog(chalk2.yellow(`
605
633
  Akan CLI version is mismatch with installed package. ${process.env.AKAN_VERSION} (global) vs ${installedAkanPackageJson.version} (akanjs)
606
- It may cause unexpected behavior. Run \`akan update\` to update latest akanjs.`));
634
+ It may cause unexpected behavior. Run \`akan update\` to update latest akanjs.`), undefined, "error");
607
635
  }
608
636
  for (const command of commands) {
609
637
  const targetMetas = getTargetMetas(command);
@@ -614,9 +642,19 @@ It may cause unexpected behavior. Run \`akan update\` to update latest akanjs.`)
614
642
  hidden: targetMeta.targetOption.devOnly
615
643
  });
616
644
  const targetFailureExitCode = targetMeta.targetOption.failureExitCode;
617
- if (targetFailureExitCode !== undefined)
618
- programCommand.exitOverride((error) => process.exit(error.exitCode === 0 ? 0 : targetFailureExitCode));
645
+ const usageExitCode = targetMeta.targetOption.usageExitCode ?? targetFailureExitCode;
646
+ const { onFailure } = targetMeta.targetOption;
619
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
+ });
620
658
  for (const argMeta of allArgMetas) {
621
659
  if (argMeta.type === "Option")
622
660
  programCommand = handleOption(programCommand, argMeta);
@@ -643,6 +681,7 @@ It may cause unexpected behavior. Run \`akan update\` to update latest akanjs.`)
643
681
  Logger.rawLog();
644
682
  const cmdArgs = args.slice(0, args.length - 2);
645
683
  const opt = args[args.length - 2];
684
+ reportFailure = async (failure) => await onFailure?.(failure, { usage: false, given: givenOptionsOf(allArgMetas, opt) });
646
685
  const commandArgs = [];
647
686
  if (targetMeta.targetOption.runsOnWorkspaceRoot)
648
687
  await assertCurrentDirectoryIsWorkspaceRoot();
@@ -681,13 +720,18 @@ It may cause unexpected behavior. Run \`akan update\` to update latest akanjs.`)
681
720
  }
682
721
  }
683
722
  }
684
- await program.parseAsync(process.argv).catch((error) => {
723
+ await program.parseAsync(process.argv).catch(async (error) => {
685
724
  printCliError(error);
725
+ await reportFailure(error).catch(printCliError);
686
726
  process.exit(ExitCodeError.codeOf(error) ?? failureExitCode);
687
727
  });
688
728
  };
689
729
  // pkgs/@akanjs/devkit/commandDecorators/commandBuilder.ts
690
- 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
+ };
691
735
 
692
736
  class TargetBuilder {
693
737
  targetOption;
@@ -758,4 +802,4 @@ function command(refName, depsOrBuilder, builder) {
758
802
  }
759
803
  return CommandBase;
760
804
  }
761
- 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,16 +1,16 @@
1
1
  // @bun
2
2
  import {
3
3
  jsonText
4
- } from "./index-trpasv9q.js";
4
+ } from "./index-yyxy7aff.js";
5
5
  import {
6
6
  akanMcpInstallTargets
7
- } from "./index-5edzv8fn.js";
7
+ } from "./index-aqwdjn4x.js";
8
8
  import {
9
9
  script
10
- } from "./index-jw1zm273.js";
10
+ } from "./index-fbw3kmt5.js";
11
11
  import {
12
12
  ContextRunner2
13
- } from "./index-d72hfmdm.js";
13
+ } from "./index-cgexcnwd.js";
14
14
 
15
15
  // pkgs/@akanjs/cli/context/context.script.ts
16
16
  import { Logger } from "akanjs/common";
@@ -1,12 +1,12 @@
1
1
  // @bun
2
2
  import {
3
3
  script
4
- } from "./index-jw1zm273.js";
4
+ } from "./index-fbw3kmt5.js";
5
5
  import {
6
6
  AppExecutor,
7
7
  LibExecutor,
8
8
  ModuleExecutor
9
- } from "./index-va06nr10.js";
9
+ } from "./index-n8dsax1f.js";
10
10
  import {
11
11
  workflowStatus,
12
12
  compactDiagnostics,
@@ -41,10 +41,10 @@ import {
41
41
  hasSignalFactoryEntry,
42
42
  insertSignalFactoryEntry,
43
43
  addFieldUiPolicyForType
44
- } from "./index-trpasv9q.js";
44
+ } from "./index-yyxy7aff.js";
45
45
  import {
46
46
  ModuleScript
47
- } from "./index-fmzcs8v6.js";
47
+ } from "./index-j4dzazmw.js";
48
48
 
49
49
  // pkgs/@akanjs/cli/primitive/primitive.script.ts
50
50
  import { capitalize, lowerlize } from "akanjs/common";
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-jw1zm273.js";
5
+ } from "./index-fbw3kmt5.js";
6
6
  import {
7
7
  ModuleExecutor
8
- } from "./index-va06nr10.js";
8
+ } from "./index-n8dsax1f.js";
9
9
  import {
10
10
  sourceFile,
11
11
  moduleSourcePaths,
@@ -13,10 +13,10 @@ import {
13
13
  createPassedPrimitiveReport,
14
14
  bilingualLabelForField,
15
15
  bilingualDescriptionForField
16
- } from "./index-trpasv9q.js";
16
+ } from "./index-yyxy7aff.js";
17
17
  import {
18
18
  PageScript
19
- } from "./index-86jt2a0e.js";
19
+ } from "./index-qh73jnyb.js";
20
20
  import {
21
21
  pluralizeName
22
22
  } from "./index-nz8prx9g.js";