@akanjs/cli 3.0.0-alpha.1 → 3.0.0-alpha.100

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 (162) hide show
  1. package/.build-stamp +1 -1
  2. package/README.ko.md +1 -1
  3. package/README.md +1 -1
  4. package/{abstractCompactor-e5yq60qz.js → abstractCompactor-byytxs22.js} +3 -5
  5. package/{agent.command-yv00p0s0.js → agent.command-v1a4746v.js} +11 -12
  6. package/{application.command-0qsczf4k.js → application.command-fzdcnzhg.js} +65 -37
  7. package/{applicationBuildRunner-ct2pxyvw.js → applicationBuildRunner-s4gsk728.js} +28 -24
  8. package/{applicationReleasePackager-gg8ccbeh.js → applicationReleasePackager-28v9vbzk.js} +8 -9
  9. package/buildBatch.proc.js +12 -13
  10. package/capacitorApp-8d6d4zkm.js +12 -0
  11. package/{cloud.command-dxfv18sa.js → cloud.command-wygy2z05.js} +15 -17
  12. package/commandManifest.json +1 -1
  13. package/{context.command-8d9e3k6b.js → context.command-4vdt1aqq.js} +19 -22
  14. package/dependencyScanner-shs82ynp.js +8 -0
  15. package/devTui-qnf1txdz.js +553 -0
  16. package/devTuiView-yzct2cq6.js +9 -0
  17. package/getDirname-dr3jz1xg.js +7 -0
  18. package/{guideline.command-3jbkxzh6.js → guideline.command-p92dq6ts.js} +16 -17
  19. package/guidelines/agentRule/agentRule.generate.json +31 -0
  20. package/guidelines/agentRule/agentRule.instruction.md +533 -0
  21. package/guidelines/conventions/conventions.generate.json +25 -0
  22. package/guidelines/conventions/conventions.instruction.md +908 -0
  23. package/guidelines/cssRule/cssRule.instruction.md +7 -0
  24. package/guidelines/framework/framework.generate.json +3 -2
  25. package/guidelines/framework/framework.instruction.md +1 -9
  26. package/guidelines/mcpRule/mcpRule.generate.json +25 -0
  27. package/guidelines/mcpRule/mcpRule.instruction.md +217 -0
  28. package/guidelines/modelStore/modelStore.instruction.md +12 -0
  29. package/guidelines/modelTemplate/modelTemplate.instruction.md +5 -0
  30. package/guidelines/queryRule/queryRule.generate.json +31 -0
  31. package/guidelines/queryRule/queryRule.instruction.md +175 -0
  32. package/guidelines/runtimeRule/runtimeRule.generate.json +25 -0
  33. package/guidelines/runtimeRule/runtimeRule.instruction.md +220 -0
  34. package/guidelines/ssrRule/ssrRule.instruction.md +49 -5
  35. package/guidelines/transportRule/transportRule.generate.json +31 -0
  36. package/guidelines/transportRule/transportRule.instruction.md +60 -0
  37. package/guidelines/workspaceOnboarding/workspaceOnboarding.generate.json +24 -0
  38. package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +263 -0
  39. package/guidelines/workspaceRecipes/workspaceRecipes.generate.json +33 -0
  40. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +402 -0
  41. package/incrementalBuilder.proc.js +26 -24
  42. package/{index-mr5s7mqd.js → index-0amdxycf.js} +8 -8
  43. package/{index-t3723f99.js → index-1yxtbmbj.js} +111 -42
  44. package/{index-ej426mcr.js → index-29sxqfaw.js} +65 -38
  45. package/index-3d9y066c.js +76 -0
  46. package/{index-76rn3g2c.js → index-47pj3aee.js} +4 -4
  47. package/index-5svjba73.js +159 -0
  48. package/index-6wwzs1bc.js +7 -0
  49. package/{index-k95xkh4p.js → index-7d6vny25.js} +16 -12
  50. package/{index-ec09pws3.js → index-8p8p0cf8.js} +14 -14
  51. package/{index-wnp7hwq7.js → index-92zztqy1.js} +7 -7
  52. package/{index-fgc8r6dj.js → index-a5vmm6x4.js} +3 -1
  53. package/{index-xys926f2.js → index-by5gpp8x.js} +4 -4
  54. package/{index-0cj2zxbm.js → index-c69j78kk.js} +12 -11
  55. package/{index-rzwcpcc3.js → index-fc1bh0a7.js} +4 -4
  56. package/{index-7c6k4yvg.js → index-gq44bqjt.js} +58 -25
  57. package/{index-a00jg8x8.js → index-gtmz74tj.js} +79 -55
  58. package/{index-tdbas9r0.js → index-h7yw2z9n.js} +7 -7
  59. package/{index-bjpxzr6s.js → index-hwkygn9s.js} +51 -3
  60. package/{index-bbkek1bp.js → index-hyywke0f.js} +1 -1
  61. package/{index-46tjzh6s.js → index-kcxmv48c.js} +29 -29
  62. package/{index-xjd3rqzj.js → index-n68jx79w.js} +6 -15
  63. package/{index-pyt2b4nw.js → index-p5neav9b.js} +1129 -1356
  64. package/{index-67546d0j.js → index-q0y2jq9j.js} +14 -2
  65. package/{index-bekddz9q.js → index-qkk27bk6.js} +32 -32
  66. package/{index-hgna5rjy.js → index-qsq3q8fy.js} +1034 -257
  67. package/{index-2q1f5j9k.js → index-srdssqj7.js} +18 -18
  68. package/{index-rh16j3c7.js → index-w8kmx1b6.js} +23 -13
  69. package/{index-nm6wghb6.js → index-yks023mb.js} +13 -13
  70. package/{index-1pvex4az.js → index-yza7zkpt.js} +94 -61
  71. package/{index-yzmhasdb.js → index-zmjppp25.js} +57 -57
  72. package/{index-8hsbnyes.js → index-znynzt5w.js} +100 -30
  73. package/{index-zasydjxd.js → index-zxgr3s8s.js} +31 -30
  74. package/{index-e16gnn26.js → index-zz5jyd94.js} +1002 -128
  75. package/index.js +22 -24
  76. package/{library.command-ebdj1vnm.js → library.command-s4fszngs.js} +11 -9
  77. package/{localRegistry.command-gb178ne8.js → localRegistry.command-gyw4da9z.js} +20 -22
  78. package/{module.command-9c1bnsx4.js → module.command-6n7dwvav.js} +13 -15
  79. package/{package.command-t93p4jkj.js → package.command-gr82ypnr.js} +8 -9
  80. package/package.json +5 -7
  81. package/{page.command-k3k0meh2.js → page.command-7gvgb3jb.js} +7 -8
  82. package/{primitive.command-de6nktdt.js → primitive.command-tk5ckw38.js} +13 -15
  83. package/{quality.command-z5kth2wa.js → quality.command-38v81baf.js} +229 -138
  84. package/recipeScanner-fpagtgc1.js +11 -0
  85. package/{repair.command-ehf2g112.js → repair.command-5xbwvsxp.js} +12 -13
  86. package/{routeSourceValidator-cncd92fv.js → routeSourceValidator-ze6x894c.js} +2 -40
  87. package/{scalar.command-7a2jtv33.js → scalar.command-0epwcr5k.js} +11 -13
  88. package/subspace.command-e2t36xb2.js +755 -0
  89. package/templates/app/env/env.client.debug.ts.template +1 -5
  90. package/templates/app/env/env.client.develop.ts.template +1 -5
  91. package/templates/app/env/env.client.local.ts.template +1 -5
  92. package/templates/app/env/env.client.main.ts.template +1 -5
  93. package/templates/app/env/env.client.testing.ts.template +1 -5
  94. package/templates/app/env/env.client.type.ts +2 -6
  95. package/templates/app/env/env.server.debug.ts.template +1 -5
  96. package/templates/app/env/env.server.develop.ts.template +1 -5
  97. package/templates/app/env/env.server.local.ts.template +1 -5
  98. package/templates/app/env/env.server.main.ts.template +1 -5
  99. package/templates/app/main.ts +3 -1
  100. package/templates/app/page/styles.css.template +3 -3
  101. package/templates/appSample/lib/task/task.signal.ts +11 -6
  102. package/templates/appSample/srvkit/AuthGuard.ts +9 -5
  103. package/templates/appSample/srvkit/SessionInternalArg.ts +4 -3
  104. package/templates/crudPages/[__model__Id]/edit/page.tsx +6 -6
  105. package/templates/crudPages/[__model__Id]/page.tsx +10 -13
  106. package/templates/crudPages/new/page.tsx +6 -6
  107. package/templates/crudPages/page.tsx +9 -9
  108. package/templates/crudSinglePage/page.tsx +11 -7
  109. package/templates/env/_env.server.type.ts +7 -5
  110. package/templates/lib/db.ts +4 -2
  111. package/templates/lib/dict.ts +1 -1
  112. package/templates/lib/sig.ts +5 -1
  113. package/templates/lib/srv.ts +6 -2
  114. package/templates/lib/useClient.ts +9 -3
  115. package/templates/module/__Model__.Util.tsx +1 -1
  116. package/templates/module/__Model__.Zone.tsx +3 -5
  117. package/templates/module/__model__.dictionary.ts +4 -1
  118. package/templates/module/__model__.signal.ts +2 -3
  119. package/templates/module/__model__.store.ts +1 -2
  120. package/templates/workspaceRoot/.gitignore.template +0 -1
  121. package/templates/workspaceRoot/.husky/pre-commit.template +16 -0
  122. package/templates/workspaceRoot/.vscode/settings.json.template +1 -1
  123. package/templates/workspaceRoot/AGENTS.md.template +4 -948
  124. package/templates/workspaceRoot/CLAUDE.md.template +19 -0
  125. package/templates/workspaceRoot/biome.json.template +4 -198
  126. package/templates/workspaceRoot/docs/AI-DEVELOPMENT.md.template +15 -16
  127. package/templates/workspaceRoot/docs/GENERATED.md.template +12 -10
  128. package/templates/workspaceRoot/package.json.template +2 -4
  129. package/typeChecker-3xgrzc2v.js +7 -0
  130. package/typecheck.proc.js +4 -5
  131. package/{workflow.command-e0tt0vk2.js → workflow.command-kphbr7eh.js} +21 -23
  132. package/{workspace.command-fpda0evj.js → workspace.command-j1gatz3d.js} +108 -91
  133. package/capacitorApp-4r9sm3qg.js +0 -58
  134. package/dependencyScanner-f6grrep3.js +0 -9
  135. package/index-mxvakhsm.js +0 -66
  136. package/index-r24hmh0q.js +0 -4
  137. package/recipeScanner-tghkzrrt.js +0 -12
  138. package/templates/libRoot/base/baseLogic.ts +0 -14
  139. package/templates/libRoot/base/index.ts +0 -8
  140. package/templates/workspaceRoot/.cursor/rules/akan-page-routing.mdc.template +0 -43
  141. package/templates/workspaceRoot/.cursor/rules/akan-sync-conventions.mdc.template +0 -33
  142. package/templates/workspaceRoot/.cursor/rules/application-test-commands.mdc.template +0 -16
  143. package/templates/workspaceRoot/.cursor/rules/change-scope.mdc.template +0 -12
  144. package/templates/workspaceRoot/.cursor/rules/client-server-boundaries.mdc.template +0 -18
  145. package/templates/workspaceRoot/.cursor/rules/coding-comments.mdc.template +0 -25
  146. package/templates/workspaceRoot/.cursor/rules/coding-style.mdc.template +0 -44
  147. package/templates/workspaceRoot/.cursor/rules/domain-module-conventions.mdc.template +0 -17
  148. package/templates/workspaceRoot/.cursor/rules/format-lint.mdc.template +0 -12
  149. package/templates/workspaceRoot/.cursor/rules/lint-enforced-rules.mdc.template +0 -18
  150. package/templates/workspaceRoot/.cursor/rules/module-file-playbook.mdc.template +0 -61
  151. package/templates/workspaceRoot/.cursor/rules/naming-conventions.mdc.template +0 -15
  152. package/templates/workspaceRoot/.cursor/rules/react-component-style.mdc.template +0 -21
  153. package/templates/workspaceRoot/.cursor/rules/repo-overview.mdc.template +0 -17
  154. package/templates/workspaceRoot/.cursor/rules/scalar-modeling.mdc.template +0 -58
  155. package/templates/workspaceRoot/.cursor/rules/secrets-and-env.mdc.template +0 -13
  156. package/templates/workspaceRoot/.cursor/rules/service-signal-conventions.mdc.template +0 -83
  157. package/templates/workspaceRoot/.cursor/rules/srvkit-adapters-and-guards.mdc.template +0 -50
  158. package/templates/workspaceRoot/.cursor/rules/ssr-first.mdc.template +0 -59
  159. package/templates/workspaceRoot/.cursor/rules/typescript-imports.mdc.template +0 -16
  160. package/typeChecker-kravn7ns.js +0 -8
  161. /package/{index-0wae5ebk.js → index-meh558jy.js} +0 -0
  162. /package/{index-ss469dec.js → index-nz8prx9g.js} +0 -0
@@ -1,34 +1,34 @@
1
1
  // @bun
2
2
  import {
3
- PageScript
4
- } from "./index-bbkek1bp.js";
5
- import {
6
- pluralizeName
7
- } from "./index-ss469dec.js";
3
+ FileSys
4
+ } from "./index-q0y2jq9j.js";
8
5
  import {
9
6
  AiSession
10
- } from "./index-0cj2zxbm.js";
7
+ } from "./index-c69j78kk.js";
11
8
  import {
12
- bilingualDescriptionForField,
13
- bilingualLabelForField,
14
- createPassedPrimitiveReport,
15
- generatedFilesForSync,
16
- moduleSourcePaths,
17
- sourceFile
18
- } from "./index-rzwcpcc3.js";
19
- import {
20
- Prompter
21
- } from "./index-tdbas9r0.js";
9
+ ModuleExecutor
10
+ } from "./index-qsq3q8fy.js";
22
11
  import {
23
12
  runner,
24
13
  script
25
- } from "./index-8hsbnyes.js";
14
+ } from "./index-znynzt5w.js";
26
15
  import {
27
- ModuleExecutor
28
- } from "./index-hgna5rjy.js";
16
+ sourceFile,
17
+ moduleSourcePaths,
18
+ generatedFilesForSync,
19
+ createPassedPrimitiveReport,
20
+ bilingualLabelForField,
21
+ bilingualDescriptionForField
22
+ } from "./index-fc1bh0a7.js";
29
23
  import {
30
- FileSys
31
- } from "./index-67546d0j.js";
24
+ PageScript
25
+ } from "./index-hyywke0f.js";
26
+ import {
27
+ Prompter
28
+ } from "./index-h7yw2z9n.js";
29
+ import {
30
+ pluralizeName
31
+ } from "./index-nz8prx9g.js";
32
32
 
33
33
  // pkgs/@akanjs/devkit/getRelatedCnsts.ts
34
34
  import { readFileSync, realpathSync } from "fs";
@@ -662,39 +662,39 @@ class ModuleRunner extends runner("module") {
662
662
  }
663
663
 
664
664
  // pkgs/@akanjs/cli/module/module.script.ts
665
- var moduleChangedFiles = (sys2, moduleName, files) => Object.values(files).map((file) => sourceFile(sys2, `lib/${moduleName}/${file.filename}`, "create", "Module source file was created."));
665
+ var moduleChangedFiles = (sys, moduleName, files) => Object.values(files).map((file) => sourceFile(sys, `lib/${moduleName}/${file.filename}`, "create", "Module source file was created."));
666
666
 
667
667
  class ModuleScript extends script("module", [ModuleRunner, PageScript]) {
668
- async createModuleTemplate(sys2, name, { page = false } = {}) {
669
- const mod = ModuleExecutor.from(sys2, name);
668
+ async createModuleTemplate(sys, name, { page = false } = {}) {
669
+ const mod = ModuleExecutor.from(sys, name);
670
670
  const files = await this.moduleRunner.createModuleTemplate(mod);
671
- if (page && sys2.type === "app")
672
- await this.pageScript.createCrudPage(mod, { app: sys2, basePath: null, single: false });
673
- await sys2.scan();
671
+ if (page && sys.type === "app")
672
+ await this.pageScript.createCrudPage(mod, { app: sys, basePath: null, single: false });
673
+ await sys.scan();
674
674
  return createPassedPrimitiveReport({
675
675
  command: "create-module",
676
- changedFiles: moduleChangedFiles(sys2, name, files),
677
- generatedFiles: generatedFilesForSync(sys2, "Generated files were refreshed after module creation."),
678
- target: sys2.name
676
+ changedFiles: moduleChangedFiles(sys, name, files),
677
+ generatedFiles: generatedFilesForSync(sys, "Generated files were refreshed after module creation."),
678
+ target: sys.name
679
679
  });
680
680
  }
681
- async createModule(sys2, name, {
681
+ async createModule(sys, name, {
682
682
  page = false,
683
683
  description,
684
684
  schemaDescription
685
685
  } = {}) {
686
- const isContinued = await sys2.exists(`lib/${name}/${name}.constant.ts`);
687
- const session = new AiSession("createModule", { workspace: sys2.workspace, cacheKey: name, isContinued });
688
- const moduleConstantExampleFiles = await sys2.workspace.getConstantFiles();
689
- const executor = ModuleExecutor.from(sys2, name);
686
+ const isContinued = await sys.exists(`lib/${name}/${name}.constant.ts`);
687
+ const session = new AiSession("createModule", { workspace: sys.workspace, cacheKey: name, isContinued });
688
+ const moduleConstantExampleFiles = await sys.workspace.getConstantFiles();
689
+ const executor = ModuleExecutor.from(sys, name);
690
690
  const files = await this.moduleRunner.createModuleTemplate(executor);
691
691
  const { constant, dictionary } = files;
692
- if (page && sys2.type === "app")
693
- await this.pageScript.createCrudPage(executor, { app: sys2, basePath: null, single: false });
692
+ if (page && sys.type === "app")
693
+ await this.pageScript.createCrudPage(executor, { app: sys, basePath: null, single: false });
694
694
  const modelDesc = description ?? await input({ message: "description of module" });
695
695
  const modelSchemaDesign = schemaDescription ?? await input({ message: "schema description of module" });
696
- const config = await sys2.getConfig();
697
- const moduleRequest = new ModuleRequest({ sysType: sys2.type, sysName: sys2.name, modelName: name, config });
696
+ const config = await sys.getConfig();
697
+ const moduleRequest = new ModuleRequest({ sysType: sys.type, sysName: sys.name, modelName: name, config });
698
698
  const constantRequestPrompt = await moduleRequest.requestModelConstant({
699
699
  modelDesc,
700
700
  modelSchemaDesign,
@@ -702,38 +702,38 @@ class ModuleScript extends script("module", [ModuleRunner, PageScript]) {
702
702
  exampleFiles: randomPicks(moduleConstantExampleFiles, Math.min(10, moduleConstantExampleFiles.length))
703
703
  });
704
704
  const constantGuide = await ModuleRequest.getGuideJson("modelConstant");
705
- const constantWrites = await session.writeTypescripts(constantRequestPrompt, sys2, {
705
+ const constantWrites = await session.writeTypescripts(constantRequestPrompt, sys, {
706
706
  validate: constantGuide.update.rules
707
707
  });
708
708
  for (const scalarName of this.#getCreatedScalarNames(constantWrites.map(({ filePath }) => filePath))) {
709
- await sys2.applyTemplate({
709
+ await sys.applyTemplate({
710
710
  basePath: "./lib/__scalar",
711
711
  template: "__scalar",
712
- dict: { model: scalarName, models: pluralizeName(scalarName), sysName: sys2.name },
712
+ dict: { model: scalarName, models: pluralizeName(scalarName), sysName: sys.name },
713
713
  overwrite: false
714
714
  });
715
715
  }
716
- const constantContent = await sys2.readFile(`lib/${name}/${name}.constant.ts`);
716
+ const constantContent = await sys.readFile(`lib/${name}/${name}.constant.ts`);
717
717
  const dictionaryGuide = await ModuleRequest.getGuideJson("modelDictionary");
718
718
  await session.writeTypescripts(requestDictionary({
719
- sysName: sys2.name,
719
+ sysName: sys.name,
720
720
  modelName: name,
721
721
  constant: constantContent,
722
722
  modelDesc,
723
723
  modelSchemaDesign,
724
724
  boilerplate: dictionary.content,
725
725
  exampleFiles: randomPicks(moduleConstantExampleFiles, Math.min(10, moduleConstantExampleFiles.length))
726
- }), sys2, { validate: dictionaryGuide.update.rules });
727
- await sys2.scan();
728
- sys2.log(`Module ${name} created in ${sys2.type}s/${sys2.name}/lib/${name}`);
726
+ }), sys, { validate: dictionaryGuide.update.rules });
727
+ await sys.scan();
728
+ sys.log(`Module ${name} created in ${sys.type}s/${sys.name}/lib/${name}`);
729
729
  return createPassedPrimitiveReport({
730
730
  command: "create-module",
731
731
  changedFiles: [
732
- ...moduleChangedFiles(sys2, name, files),
733
- ...constantWrites.map((write) => sourceFile(sys2, write.filePath, "modify", "AI-assisted module constant source was updated."))
732
+ ...moduleChangedFiles(sys, name, files),
733
+ ...constantWrites.map((write) => sourceFile(sys, write.filePath, "modify", "AI-assisted module constant source was updated."))
734
734
  ],
735
- generatedFiles: generatedFilesForSync(sys2, "Generated files were refreshed after module creation."),
736
- target: sys2.name
735
+ generatedFiles: generatedFilesForSync(sys, "Generated files were refreshed after module creation."),
736
+ target: sys.name
737
737
  });
738
738
  }
739
739
  #getCreatedScalarNames(filePaths) {
@@ -744,15 +744,15 @@ class ModuleScript extends script("module", [ModuleRunner, PageScript]) {
744
744
  async removeModule(mod) {
745
745
  await this.moduleRunner.removeModule(mod);
746
746
  }
747
- async createService(sys2, name) {
748
- const service = ModuleExecutor.from(sys2, `_${name}`);
747
+ async createService(sys, name) {
748
+ const service = ModuleExecutor.from(sys, `_${name}`);
749
749
  const files = await this.moduleRunner.createService(service);
750
- await sys2.scan();
750
+ await sys.scan();
751
751
  return createPassedPrimitiveReport({
752
752
  command: "create-service",
753
- changedFiles: moduleChangedFiles(sys2, `_${name}`, files),
754
- generatedFiles: generatedFilesForSync(sys2, "Generated files were refreshed after service creation."),
755
- target: sys2.name
753
+ changedFiles: moduleChangedFiles(sys, `_${name}`, files),
754
+ generatedFiles: generatedFilesForSync(sys, "Generated files were refreshed after service creation."),
755
+ target: sys.name
756
756
  });
757
757
  }
758
758
  async createTest(workspace, name) {}
@@ -1,19 +1,18 @@
1
1
  // @bun
2
2
  import {
3
- AppExecutor,
3
+ FileSys
4
+ } from "./index-q0y2jq9j.js";
5
+ import {
4
6
  Executor,
7
+ WorkspaceExecutor,
8
+ AppExecutor,
5
9
  LibExecutor,
6
- ModuleExecutor,
7
10
  PkgExecutor,
8
- WorkspaceExecutor,
9
- getDirname
10
- } from "./index-hgna5rjy.js";
11
+ ModuleExecutor
12
+ } from "./index-qsq3q8fy.js";
11
13
  import {
12
- FileSys
13
- } from "./index-67546d0j.js";
14
- import {
15
- __require
16
- } from "./index-r24hmh0q.js";
14
+ getDirname2
15
+ } from "./index-6wwzs1bc.js";
17
16
 
18
17
  // pkgs/@akanjs/devkit/commandDecorators/targetMeta.ts
19
18
  var COMMAND_META = Symbol("akan.command.meta");
@@ -52,6 +51,7 @@ var normalizePrimitiveArgType = (type) => {
52
51
  throw new Error(`Invalid primitive argument type: ${type}`);
53
52
  };
54
53
  var App = createInternalArgToken("App");
54
+ var Apps = createInternalArgToken("Apps");
55
55
  var Lib = createInternalArgToken("Lib");
56
56
  var Sys = createInternalArgToken("Sys");
57
57
  var Exec = createInternalArgToken("Exec");
@@ -60,11 +60,29 @@ var Module = createInternalArgToken("Module");
60
60
  var Workspace = createInternalArgToken("Workspace");
61
61
 
62
62
  // pkgs/@akanjs/devkit/commandDecorators/command.ts
63
- import path from "path";
63
+ import path2 from "path";
64
64
  import { Logger } from "akanjs/common";
65
65
  import chalk2 from "chalk";
66
66
  import { program } from "commander";
67
67
 
68
+ // pkgs/@akanjs/devkit/appSelectionMemory.ts
69
+ import path from "path";
70
+ class AppSelectionMemory {
71
+ static pathIn(workspaceRoot) {
72
+ return path.join(workspaceRoot, "local", ".akan", "lastStart.json");
73
+ }
74
+ static async read(workspaceRoot) {
75
+ const stored = await Bun.file(AppSelectionMemory.pathIn(workspaceRoot)).json().catch(() => null);
76
+ const apps = stored?.apps;
77
+ return Array.isArray(apps) ? apps.filter((name) => typeof name === "string") : [];
78
+ }
79
+ static async write(workspaceRoot, apps) {
80
+ await FileSys.writeJson(AppSelectionMemory.pathIn(workspaceRoot), { apps }).catch(() => {
81
+ return;
82
+ });
83
+ }
84
+ }
85
+
68
86
  // pkgs/@akanjs/devkit/commandDecorators/dependencyBuilder.ts
69
87
  var capitalize = (value) => value.slice(0, 1).toUpperCase() + value.slice(1);
70
88
  var createDependencyKey = (refName, kind) => `${refName}${capitalize(kind)}`;
@@ -262,6 +280,8 @@ var formatCommandHelp = (command, key) => {
262
280
  return "";
263
281
  if (arg.type === "Module")
264
282
  return "[sys:module]";
283
+ if (arg.type === "Apps")
284
+ return "[apps...]";
265
285
  if (arg.type === "Argument") {
266
286
  return `[${camelToKebabCase2(arg.name)}]`;
267
287
  }
@@ -288,6 +308,9 @@ var formatCommandHelp = (command, key) => {
288
308
  } else if (arg.type === "Module") {
289
309
  argName = "sys:module";
290
310
  argDesc = "Module in format: app-name:module-name or lib-name:module-name";
311
+ } else if (arg.type === "Apps") {
312
+ argName = "apps...";
313
+ argDesc = "App names, space- or comma-separated, or all. Omit to pick them interactively";
291
314
  } else {
292
315
  argName = arg.type.toLowerCase();
293
316
  argDesc = `${arg.type} name in this workspace`;
@@ -381,6 +404,17 @@ var prompts = async () => await import("@inquirer/prompts");
381
404
  var select = (config, context) => prompts().then((m) => m.select(config, context));
382
405
  var confirm = (config, context) => prompts().then((m) => m.confirm(config, context));
383
406
  var input = (config, context) => prompts().then((m) => m.input(config, context));
407
+ var checkbox = (config, context) => prompts().then((m) => m.checkbox(config, context));
408
+ var assertEnumChoice = (argMeta, value) => {
409
+ const enumChoices = argMeta.argsOption.enum;
410
+ if (!enumChoices || typeof enumChoices === "function")
411
+ return;
412
+ const choices = normalizeEnumChoices(enumChoices);
413
+ if (choices.some((choice) => String(choice.value) === String(value)))
414
+ return;
415
+ const label = argMeta.type === "Option" ? `option '--${camelToKebabCase3(argMeta.name)}'` : `argument '${argMeta.name}'`;
416
+ throw new Error(`${label} argument '${String(value)}' is invalid. Allowed choices are ${choices.map((choice) => choice.name).join(", ")}.`);
417
+ };
384
418
  var resolveEnumChoices = async (argMeta, context) => {
385
419
  const enumChoices = argMeta.argsOption.enum;
386
420
  if (!enumChoices)
@@ -394,9 +428,10 @@ var getOptionValue = async (argMeta, opt, context) => {
394
428
  name,
395
429
  argsOption: { enum: enumChoices, default: defaultValue, type, desc, nullable, example, ask }
396
430
  } = argMeta;
397
- if (opt[argMeta.name] !== undefined)
431
+ if (opt[argMeta.name] !== undefined) {
432
+ assertEnumChoice(argMeta, opt[argMeta.name]);
398
433
  return convertArgValue(opt[argMeta.name], type ?? "string");
399
- else if (defaultValue !== undefined)
434
+ } else if (defaultValue !== undefined)
400
435
  return defaultValue;
401
436
  if (enumChoices) {
402
437
  const choices = normalizeEnumChoices(await resolveEnumChoices(argMeta, context) ?? []);
@@ -422,9 +457,10 @@ var getArgumentValue = async (argMeta, value) => {
422
457
  name,
423
458
  argsOption: { default: defaultValue, type, desc, nullable, example, ask }
424
459
  } = argMeta;
425
- if (value !== undefined)
460
+ if (value !== undefined) {
461
+ assertEnumChoice(argMeta, value);
426
462
  return convertArgValue(value, type ?? "string");
427
- else if (defaultValue !== undefined)
463
+ } else if (defaultValue !== undefined)
428
464
  return defaultValue;
429
465
  else if (nullable)
430
466
  return null;
@@ -463,6 +499,31 @@ var assertCurrentDirectoryIsWorkspaceRoot = async () => {
463
499
  ].join(`
464
500
  `));
465
501
  };
502
+ var parseAppNameList = (value) => (Array.isArray(value) ? value : value === undefined ? [] : [value]).flatMap((entry) => entry.split(",")).map((entry) => entry.trim()).filter(Boolean);
503
+ var getAppsArgumentValue = async (value, workspace) => {
504
+ const appNames = await workspace.getApps();
505
+ if (appNames.length === 0)
506
+ throw new Error("No apps found in this workspace (apps/<appName>/akan.config.ts)");
507
+ const requested = parseAppNameList(value);
508
+ if (requested.includes("all"))
509
+ return appNames.map((name) => AppExecutor.from(workspace, name));
510
+ if (requested.length) {
511
+ const unknown = requested.filter((name) => !appNames.includes(name));
512
+ if (unknown.length)
513
+ throw new Error(`Unknown app${unknown.length > 1 ? "s" : ""}: ${unknown.join(", ")}. Available: ${appNames.join(", ")}, all`);
514
+ return [...new Set(requested)].map((name) => AppExecutor.from(workspace, name));
515
+ }
516
+ if (appNames.length === 1 && appNames[0])
517
+ return [AppExecutor.from(workspace, appNames[0])];
518
+ const remembered = new Set(await AppSelectionMemory.read(workspace.workspaceRoot));
519
+ const picked = await checkbox({
520
+ message: "Select the apps to run (space to toggle, enter to confirm)",
521
+ choices: appNames.map((name) => ({ name, value: name, checked: remembered.has(name) })),
522
+ required: true
523
+ });
524
+ await AppSelectionMemory.write(workspace.workspaceRoot, picked);
525
+ return picked.map((name) => AppExecutor.from(workspace, name));
526
+ };
466
527
  var getInternalArgumentValue = async (argMeta, value, workspace) => {
467
528
  if (argMeta.type === "Workspace")
468
529
  return workspace;
@@ -526,36 +587,36 @@ var getInternalArgumentValue = async (argMeta, value, workspace) => {
526
587
  return PkgExecutor.from(workspace, pkgName);
527
588
  } else if (sysType === "module") {
528
589
  if (value) {
529
- const [sysName, moduleName2] = value.split(":");
530
- if (!sysName || !moduleName2)
590
+ const [sysName, moduleName] = value.split(":");
591
+ if (!sysName || !moduleName)
531
592
  throw new Error(`Invalid module name: ${value}`);
532
593
  if (appNames.includes(sysName)) {
533
594
  const app = AppExecutor.from(workspace, sysName);
534
- const modules2 = await app.getModules();
535
- if (modules2.includes(moduleName2))
536
- return ModuleExecutor.from(app, moduleName2);
595
+ const modules = await app.getModules();
596
+ if (modules.includes(moduleName))
597
+ return ModuleExecutor.from(app, moduleName);
537
598
  else
538
- throw new Error(`Invalid module name: ${moduleName2}`);
599
+ throw new Error(`Invalid module name: ${moduleName}`);
539
600
  } else if (libNames.includes(sysName)) {
540
601
  const lib = LibExecutor.from(workspace, sysName);
541
- const modules2 = await lib.getModules();
542
- if (modules2.includes(moduleName2))
543
- return ModuleExecutor.from(lib, moduleName2);
602
+ const modules = await lib.getModules();
603
+ if (modules.includes(moduleName))
604
+ return ModuleExecutor.from(lib, moduleName);
544
605
  } else
545
606
  throw new Error(`Invalid system name: ${sysName}`);
546
607
  }
547
608
  const { type, name } = await select({
548
609
  message: `select the App or Lib name`,
549
610
  choices: [
550
- ...appNames.map((name2) => ({ name: name2, value: { type: "app", name: name2 } })),
551
- ...libNames.map((name2) => ({ name: name2, value: { type: "lib", name: name2 } }))
611
+ ...appNames.map((name) => ({ name, value: { type: "app", name } })),
612
+ ...libNames.map((name) => ({ name, value: { type: "lib", name } }))
552
613
  ]
553
614
  });
554
615
  const executor = type === "app" ? AppExecutor.from(workspace, name) : LibExecutor.from(workspace, name);
555
616
  const modules = await executor.getModules();
556
617
  const moduleName = await select({
557
618
  message: `Select the module name`,
558
- choices: modules.map((name2) => ({ name: `${executor.name}:${name2}`, value: name2 }))
619
+ choices: modules.map((name) => ({ name: `${executor.name}:${name}`, value: name }))
559
620
  });
560
621
  return ModuleExecutor.from(executor, moduleName);
561
622
  } else
@@ -566,8 +627,8 @@ var runCommands = async (...commands) => {
566
627
  printCliError(error);
567
628
  process.exit(1);
568
629
  });
569
- const __dirname2 = getDirname(import.meta.url);
570
- const packageJsonCandidates = [`${path.dirname(Bun.main)}/package.json`, `${__dirname2}/../package.json`];
630
+ const __dirname2 = getDirname2(import.meta.url);
631
+ const packageJsonCandidates = [`${path2.dirname(Bun.main)}/package.json`, `${__dirname2}/../package.json`];
571
632
  let cliPackageJson = null;
572
633
  for (const packageJsonPath of packageJsonCandidates) {
573
634
  if (!await FileSys.fileExists(packageJsonPath))
@@ -614,6 +675,8 @@ It may cause unexpected behavior. Run \`akan update\` to update latest akanjs.`)
614
675
  continue;
615
676
  else if (argMeta.type === "Module") {
616
677
  programCommand = programCommand.argument(`[sys-name:module-name]`, `${argMeta.type} in this workspace (apps|libs)/<sys-name>/lib/<module-name>`);
678
+ } else if (argMeta.type === "Apps") {
679
+ programCommand = programCommand.argument(`[apps...]`, `apps in this workspace apps/<appName>, or all (space- or comma-separated; omit to pick interactively)`);
617
680
  } else {
618
681
  const sysType = argMeta.type.toLowerCase();
619
682
  programCommand = programCommand.argument(`[${sysType}]`, `${sysType} in this workspace ${sysType}s/<${sysType}Name>`);
@@ -638,10 +701,17 @@ It may cause unexpected behavior. Run \`akan update\` to update latest akanjs.`)
638
701
  commandArgs[argMeta.idx] = await getOptionValue(argMeta, opt, commandContext);
639
702
  else if (argMeta.type === "Argument")
640
703
  commandArgs[argMeta.idx] = await getArgumentValue(argMeta, cmdArgs[argMeta.idx]);
704
+ else if (argMeta.type === "Apps")
705
+ commandArgs[argMeta.idx] = await getAppsArgumentValue(cmdArgs[argMeta.idx], workspace);
641
706
  else
642
707
  commandArgs[argMeta.idx] = await getInternalArgumentValue(argMeta, cmdArgs[argMeta.idx], workspace);
643
708
  if (commandArgs[argMeta.idx] instanceof AppExecutor)
644
709
  process.env.AKAN_PUBLIC_APP_NAME = commandArgs[argMeta.idx].name;
710
+ else if (Array.isArray(commandArgs[argMeta.idx])) {
711
+ const apps = commandArgs[argMeta.idx];
712
+ if (apps.length === 1 && apps[0])
713
+ process.env.AKAN_PUBLIC_APP_NAME = apps[0].name;
714
+ }
645
715
  assignCommandContext(commandContext, argMeta, commandArgs[argMeta.idx]);
646
716
  if (opt.verbose)
647
717
  Executor.setVerbose(true);
@@ -761,4 +831,4 @@ function command(refName, depsOrBuilder, builder) {
761
831
  }
762
832
  return CommandBase;
763
833
  }
764
- export { getTargetMetas, getTargetCommandNames, App, Lib, Sys, Exec, Pkg, Module, Workspace, CommandContainer, runner, script, runCommands, command };
834
+ export { getTargetMetas, getTargetCommandNames, App, Apps, Lib, Sys, Exec, Pkg, Module, Workspace, CommandContainer, runner, script, runCommands, command };
@@ -1,27 +1,20 @@
1
1
  // @bun
2
2
  import {
3
- AiSession,
4
- CloudApi,
3
+ getDefaultHostConfig,
5
4
  GlobalConfig,
6
- getDefaultHostConfig
7
- } from "./index-0cj2zxbm.js";
5
+ CloudApi,
6
+ AiSession
7
+ } from "./index-c69j78kk.js";
8
8
  import {
9
- openBrowser
10
- } from "./index-e16gnn26.js";
9
+ WorkspaceExecutor,
10
+ AppExecutor
11
+ } from "./index-qsq3q8fy.js";
11
12
  import {
12
13
  runner
13
- } from "./index-8hsbnyes.js";
14
+ } from "./index-znynzt5w.js";
14
15
  import {
15
- AppExecutor,
16
- WorkspaceExecutor
17
- } from "./index-hgna5rjy.js";
18
-
19
- // pkgs/@akanjs/cli/cloud/cloud.runner.ts
20
- import path from "path";
21
- import { confirm, input, select } from "@inquirer/prompts";
22
- import { Logger, sleep } from "akanjs/common";
23
- import chalk from "chalk";
24
- import * as QRcode from "qrcode";
16
+ openBrowser
17
+ } from "./index-zz5jyd94.js";
25
18
 
26
19
  // pkgs/@akanjs/cli/npmRegistry.ts
27
20
  var defaultNpmRegistry = "https://registry.npmjs.org";
@@ -40,6 +33,11 @@ async function getLatestPackageVersion(packageName, tag = "latest", registryUrl)
40
33
  }
41
34
 
42
35
  // pkgs/@akanjs/cli/cloud/cloud.runner.ts
36
+ import path from "path";
37
+ import { confirm, input, select } from "@inquirer/prompts";
38
+ import { Logger, sleep } from "akanjs/common";
39
+ import chalk from "chalk";
40
+ import * as QRcode from "qrcode";
43
41
  var addRemoteEnvServerValue = "__addRemoteEnvServer";
44
42
  var removeRemoteEnvServerValue = "__removeRemoteEnvServer";
45
43
 
@@ -100,8 +98,8 @@ class CloudRunner extends runner("cloud") {
100
98
  const selectedName = await select({
101
99
  message: "Select the remote env server",
102
100
  choices: [
103
- ...serverEntries.map(([name, config2]) => ({
104
- name: `${name} (${config2.username ? `${config2.username}@` : ""}${config2.host}${config2.port ? `:${config2.port}` : ""})`,
101
+ ...serverEntries.map(([name, config]) => ({
102
+ name: `${name} (${config.username ? `${config.username}@` : ""}${config.host}${config.port ? `:${config.port}` : ""})`,
105
103
  value: name
106
104
  })),
107
105
  { name: "Add new remote server", value: addRemoteEnvServerValue },
@@ -205,12 +203,12 @@ ${chalk.green("\u27A4")} Authentication Required`));
205
203
  const MAX_RETRY = 300;
206
204
  for (let i = 0;i < MAX_RETRY; i++) {
207
205
  const accessToken = await cloudApi.getRemoteAuthToken(remoteId);
208
- const self2 = await cloudApi.getRemoteSelf();
209
- if (accessToken && self2) {
210
- await GlobalConfig.setHostConfig({ host: config.host, auth: { accessToken, self: self2 } });
206
+ const self = await cloudApi.getRemoteSelf();
207
+ if (accessToken && self) {
208
+ await GlobalConfig.setHostConfig({ host: config.host, auth: { accessToken, self } });
211
209
  Logger.rawLog(chalk.green(`\r\u2713 Authentication successful!`));
212
210
  Logger.rawLog(chalk.green.bold(`
213
- \u2728 Welcome aboard, ${self2.nickname ?? "anonymous"}!`));
211
+ \u2728 Welcome aboard, ${self.nickname ?? "anonymous"}!`));
214
212
  Logger.rawLog(chalk.dim(`You're now ready to use Akan CLI!
215
213
  `));
216
214
  return true;
@@ -255,12 +253,12 @@ ${chalk.green("\u27A4")} Authentication Required`));
255
253
  const isOfficialRelease = !devPatchVersion;
256
254
  const targetVersionPrefix = isOfficialRelease ? `${majorVersion}.${minorVersion}` : `${majorVersion}.${minorVersion}.${patchVersion}`;
257
255
  const tag = distTag ?? (isOfficialRelease ? "latest" : patchVersion.split("-").at(1) ?? "dev");
258
- const getNextVersion = async (prefix, tag2) => {
256
+ const getNextVersion = async (prefix, tag) => {
259
257
  try {
260
- const latestPublishedVersion2 = await getLatestPackageVersion("akanjs", tag2, registry);
261
- const latestPatch = latestPublishedVersion2.startsWith(prefix) ? parseInt(latestPublishedVersion2.split(".").at(-1) ?? "-1") : -1;
262
- const nextVersion2 = `${prefix}.${latestPatch + 1}`;
263
- return { nextVersion: nextVersion2, latestPublishedVersion: latestPublishedVersion2 };
258
+ const latestPublishedVersion = await getLatestPackageVersion("akanjs", tag, registry);
259
+ const latestPatch = latestPublishedVersion.startsWith(prefix) ? parseInt(latestPublishedVersion.split(".").at(-1) ?? "-1") : -1;
260
+ const nextVersion = `${prefix}.${latestPatch + 1}`;
261
+ return { nextVersion, latestPublishedVersion };
264
262
  } catch {
265
263
  return { nextVersion: `${prefix}.0`, latestPublishedVersion: null };
266
264
  }
@@ -285,7 +283,10 @@ ${chalk.green("\u27A4")} Authentication Required`));
285
283
  return;
286
284
  }
287
285
  }
288
- await Promise.all(akanPkgs.map(async (library) => {
286
+ Logger.info("Logging in to npm...");
287
+ await workspace.spawn("npm", ["login"], { stdio: "inherit" });
288
+ Logger.info("Logged in to npm");
289
+ for (const library of akanPkgs) {
289
290
  Logger.info(`Publishing ${library}@${nextVersion} to ${registry ?? "npm"}...`);
290
291
  await workspace.spawn("npm", ["publish", "--tag", tag, ...this.#getRegistryArgs(registry), ...this.#getLocalRegistryAuthArgs(registry)], {
291
292
  cwd: path.join(workspace.workspaceRoot, "dist/pkgs", library),
@@ -293,7 +294,7 @@ ${chalk.green("\u27A4")} Authentication Required`));
293
294
  stdio: "inherit"
294
295
  });
295
296
  Logger.info(`${library}@${nextVersion} is published to ${registry ?? "npm"}`);
296
- }));
297
+ }
297
298
  Logger.info(`All libraries are published to ${registry ?? "npm"}`);
298
299
  }
299
300
  async update(workspace, tag = "latest", { registryUrl } = {}) {