@akanjs/cli 3.0.0-beta.18 → 3.0.0-beta.19

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 (75) hide show
  1. package/.build-stamp +1 -1
  2. package/{CodeAgent-0035exh3.js → CodeAgent-6cm97kay.js} +2 -2
  3. package/{CodeAgentRpcHost-qvwfv0n9.js → CodeAgentRpcHost-p7h6n2hp.js} +1 -1
  4. package/CodeAgentRpcListener-7p7z5dd7.js +97 -0
  5. package/{CodeTui-eweg1hep.js → CodeTui-za4jsm41.js} +1 -1
  6. package/{TunnelShare-r5tc2qk5.js → TunnelShare-2j6s511d.js} +2 -2
  7. package/{agent.command-65zqfkg0.js → agent.command-e0wpbbyg.js} +5 -5
  8. package/akanCode.js +4 -4
  9. package/{application.command-2wcj5da3.js → application.command-8wyxqc8q.js} +15 -9
  10. package/{applicationBuildRunner-m0hhgwsx.js → applicationBuildRunner-n9gzaxd0.js} +31 -7
  11. package/{applicationReleasePackager-vykfzgx3.js → applicationReleasePackager-vpggfqgq.js} +1 -1
  12. package/buildBatch.proc.js +3 -3
  13. package/{capacitorApp-2daqhb5h.js → capacitorApp-q3z0qht0.js} +2 -2
  14. package/{cloud.command-960bgbf4.js → cloud.command-4zwa5dsx.js} +34 -12
  15. package/cloud.script-fwx3vb34.js +20 -0
  16. package/{code.command-4feh3ef7.js → code.command-468c9d7s.js} +41 -19
  17. package/commandManifest.json +1 -1
  18. package/{context.command-kzehkx48.js → context.command-dsnw0jby.js} +13 -13
  19. package/context.runner-rs4rj15d.js +22 -0
  20. package/{dependencyScanner-shs82ynp.js → dependencyScanner-0z2h2tks.js} +1 -1
  21. package/{guideline.command-3w2g20x4.js → guideline.command-vhw13pqr.js} +2 -2
  22. package/guidelines/agentRule/agentRule.instruction.md +27 -10
  23. package/guidelines/conventions/conventions.instruction.md +16 -4
  24. package/guidelines/queryRule/queryRule.instruction.md +16 -6
  25. package/guidelines/runtimeRule/runtimeRule.instruction.md +74 -0
  26. package/incrementalBuilder.proc.js +3 -2
  27. package/{index-dw943k93.js → index-10dkrrww.js} +4 -4
  28. package/{index-rpgxs245.js → index-18zybgkc.js} +2 -2
  29. package/{index-mt2154s2.js → index-22xtgmhn.js} +1 -1
  30. package/{index-yw6g3bbv.js → index-2446k7b4.js} +1 -1
  31. package/{index-cjw1sj1x.js → index-3jrp517k.js} +10 -10
  32. package/{index-q9c3c0hy.js → index-4m929vvn.js} +2 -2
  33. package/{index-ef228gzf.js → index-53176s7j.js} +3 -3
  34. package/{index-jwrpsrg3.js → index-667w0yah.js} +1 -1
  35. package/{index-6q589y9t.js → index-7ep8qtvp.js} +2 -2
  36. package/{index-w8kmx1b6.js → index-89hy31kf.js} +30 -7
  37. package/{index-jd01kj5r.js → index-9d6nvkz2.js} +1 -1
  38. package/{index-zq0mr3hh.js → index-a1w6934z.js} +3 -3
  39. package/{index-sbfk9daf.js → index-ab0c38ea.js} +4 -4
  40. package/index-bc88j1ry.js +1166 -0
  41. package/{index-h94faz96.js → index-bftkz6cp.js} +274 -60
  42. package/{index-kcxmv48c.js → index-bhtmj233.js} +4 -1
  43. package/{index-m41ptvat.js → index-bwf965h6.js} +3 -3
  44. package/{index-bwxpk2cj.js → index-crmeqnmf.js} +52 -26
  45. package/{index-8k16atqy.js → index-d2242ksy.js} +23 -6
  46. package/{index-jwexzh42.js → index-e4v6vhxq.js} +222 -56
  47. package/{index-pn8mhpps.js → index-esk82rvk.js} +4 -4
  48. package/{index-4r42ext5.js → index-kwaq3n9n.js} +1 -1
  49. package/{index-gm76f0qb.js → index-n3cv0tm4.js} +1 -1
  50. package/{index-ycy302an.js → index-qdgzsnhg.js} +1 -1
  51. package/{index-wcg582a8.js → index-sq2dzkzm.js} +35 -10
  52. package/{index-myj01w9r.js → index-srmay5jw.js} +15 -2
  53. package/{index-zmj143x7.js → index-txr7dj2g.js} +3 -3
  54. package/{index-erfc1x40.js → index-vqx8bdxz.js} +1 -1
  55. package/{index-d9fjz06h.js → index-zqgj2rt2.js} +4 -4
  56. package/index.js +21 -21
  57. package/{library.command-fp0nhr62.js → library.command-cqr175dy.js} +3 -3
  58. package/{localRegistry.command-8y0ecxb9.js → localRegistry.command-49z55qqz.js} +9 -9
  59. package/{module.command-kqkn48t2.js → module.command-9p8mm3b0.js} +5 -5
  60. package/{package.command-qverjh22.js → package.command-wxyz909t.js} +4 -4
  61. package/package.json +2 -2
  62. package/{page.command-94bwhd0g.js → page.command-gsrsfqqs.js} +3 -3
  63. package/{primitive.command-2ydvtah2.js → primitive.command-ns1mptje.js} +6 -6
  64. package/{quality.command-fa0gth4p.js → quality.command-e76k2q9k.js} +17 -15
  65. package/{repair.command-4qng2hpm.js → repair.command-pkrsm3cw.js} +5 -5
  66. package/{scalar.command-pb2y95sh.js → scalar.command-0cpt3fc8.js} +4 -4
  67. package/{subspace.command-vkxmwp74.js → subspace.command-fktpwp0g.js} +20 -10
  68. package/templates/appSample/lib/task/task.signal.test.ts +1 -1
  69. package/templates/localDev/docker-compose.yaml.template +3 -14
  70. package/{tunnel.command-02cvp9nf.js → tunnel.command-d5jy9gk8.js} +4 -4
  71. package/{workflow.command-132txnrh.js → workflow.command-6tkcysmx.js} +9 -9
  72. package/{workspace.command-d5wkswek.js → workspace.command-gv84eh1p.js} +24 -23
  73. package/cloud.script-qhcnqt1n.js +0 -20
  74. package/context.runner-z0rrcz7b.js +0 -22
  75. package/index-3hpxeys1.js +0 -462
@@ -195,6 +195,7 @@ import { readFileSync as readFileSync2 } from "fs";
195
195
  import {
196
196
  copyFile,
197
197
  cp as cpEntry,
198
+ lstat,
198
199
  mkdir as mkdir3,
199
200
  readdir as readDirEntries,
200
201
  realpath,
@@ -358,7 +359,7 @@ ${CLAUDE_COMMENT_RULE}
358
359
  import fs from "fs";
359
360
  import path2 from "path";
360
361
  import { fileURLToPath } from "url";
361
- import { normalizeRoutePrefix } from "akanjs/base";
362
+ import { DatabaseModes, normalizeRoutePrefix } from "akanjs/base";
362
363
  import { resolveAkanI18nConfig } from "akanjs/common";
363
364
 
364
365
  // pkgs/@akanjs/devkit/akanConfig/types.ts
@@ -417,16 +418,6 @@ var MOBILE_APP_CAPACITOR_PLUGINS = [
417
418
  "@capacitor/push-notifications",
418
419
  "capacitor-plugin-safe-area"
419
420
  ];
420
- var DATABASE_MODE_RUNTIME_PACKAGES = {
421
- single: [],
422
- multiple: ["@libsql/client", "bullmq", "ioredis", "protobufjs"],
423
- cluster: ["bullmq", "ioredis", "postgres", "protobufjs"]
424
- };
425
- var AKAN_RUNTIME_PACKAGES = new Set([
426
- ...SSR_RUNTIME_PACKAGES,
427
- ...MOBILE_RUNTIME_PACKAGES,
428
- ...Object.values(DATABASE_MODE_RUNTIME_PACKAGES).flat()
429
- ]);
430
421
  var DEFAULT_AKAN_IMAGE_CONFIG = {
431
422
  deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
432
423
  imageSizes: [32, 48, 64, 96, 128, 256, 384],
@@ -506,7 +497,7 @@ class AkanAppConfig {
506
497
  rootPackageJson;
507
498
  docker;
508
499
  dockerfile;
509
- defaultDatabaseMode;
500
+ database;
510
501
  web;
511
502
  externalLibs;
512
503
  barrelImports;
@@ -534,7 +525,7 @@ class AkanAppConfig {
534
525
  this.baseDevEnv = baseDevEnv;
535
526
  this.plugins = plugins;
536
527
  this.#applyRoutes(config?.routes);
537
- this.defaultDatabaseMode = config?.defaultDatabaseMode ?? "single";
528
+ this.database = AkanAppConfig.#database(app, config);
538
529
  this.externalLibs = [...new Set([...config?.externalLibs ?? [], ...libContributions.externalLibs])];
539
530
  this.barrelImports = [
540
531
  ...DEFAULT_BARREL_IMPORTS,
@@ -730,6 +721,7 @@ ENV AKAN_PUBLIC_LOCALES=${this.i18n.locales.join(",")}
730
721
  ENV AKAN_PUBLIC_API_PREFIX=${this.api.prefix}
731
722
  ENV AKAN_PUBLIC_WS_PREFIX=${this.api.websocketPrefix}
732
723
  ENV AKAN_PUBLIC_OPERATION_MODE=cloud
724
+ ENV AKAN_DATABASE_MODES=${this.database.modes.join(",")}
733
725
  ENV AKAN_LOG_TO_FILE=0
734
726
  ${webEnvLines}
735
727
  CMD [${command.map((c) => `"${c}"`).join(",")}]`;
@@ -774,14 +766,30 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
774
766
  return akanPackageJson.dependencies?.[lib] ?? akanPackageJson.peerDependencies?.[lib];
775
767
  }
776
768
  #getProductionRuntimePackages() {
777
- return [...this.externalLibs, ...SSR_RUNTIME_PACKAGES, ...this.getDatabaseModeRuntimePackages()];
769
+ return [
770
+ ...this.externalLibs,
771
+ ...SSR_RUNTIME_PACKAGES,
772
+ ...this.database.modes.flatMap((mode) => this.getDatabaseModeRuntimePackages(mode))
773
+ ];
778
774
  }
779
- getDatabaseModeRuntimePackages(databaseMode = this.defaultDatabaseMode) {
780
- return [...DATABASE_MODE_RUNTIME_PACKAGES[databaseMode]];
775
+ getDatabaseModeRuntimePackages(databaseMode) {
776
+ return [...DatabaseModes.drivers[databaseMode]];
781
777
  }
782
- getMissingDatabaseModeDependencySpecs(databaseMode = this.defaultDatabaseMode) {
778
+ getMissingDatabaseModeDependencySpecs(databaseMode) {
783
779
  return this.#getMissingDependencySpecs(this.getDatabaseModeRuntimePackages(databaseMode));
784
780
  }
781
+ resolveDatabaseMode() {
782
+ return DatabaseModes.resolve({
783
+ requested: process.env.AKAN_DATABASE_MODE,
784
+ declared: this.database.modes.join(","),
785
+ local: true
786
+ });
787
+ }
788
+ static #database(app, config) {
789
+ const declared = config?.database?.modes?.filter((mode) => !!mode);
790
+ const modes = declared?.length ? declared : ["single"];
791
+ return { modes: DatabaseModes.parseList(modes.join(","), `database.modes in apps/${app.name}/akan.config.ts`) };
792
+ }
785
793
  getMobileRuntimePackages() {
786
794
  return [...new Set([...MOBILE_RUNTIME_PACKAGES, ...MOBILE_APP_CAPACITOR_PLUGINS])];
787
795
  }
@@ -803,6 +811,9 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
803
811
  return `${lib}@${version}`;
804
812
  });
805
813
  }
814
+ get akanVersion() {
815
+ return getAkanPackageJson().version;
816
+ }
806
817
  getProductionPackageJson(data = {}) {
807
818
  return {
808
819
  name: this.app.name,
@@ -1286,13 +1297,14 @@ var asBiomeReport = (candidate) => {
1286
1297
  var BIOME_CONFIG_FILES = ["biome.json", "biome.jsonc"];
1287
1298
 
1288
1299
  class Linter {
1300
+ static biomeBinName = process.platform === "win32" ? "biome.exe" : "biome";
1289
1301
  lintRoot;
1290
1302
  configPath;
1291
1303
  #biomeBin;
1292
1304
  constructor(cwdPath) {
1293
1305
  this.lintRoot = this.#findBiomeRootPath(cwdPath);
1294
1306
  this.configPath = Linter.#configPathIn(this.lintRoot) ?? path5.join(this.lintRoot, "biome.json");
1295
- const localBiomeBin = path5.join(this.lintRoot, "node_modules/.bin/biome");
1307
+ const localBiomeBin = path5.join(this.lintRoot, "node_modules", ".bin", Linter.biomeBinName);
1296
1308
  this.#biomeBin = existsSync(localBiomeBin) ? localBiomeBin : "biome";
1297
1309
  }
1298
1310
  static #configPathIn(dir) {
@@ -1702,7 +1714,7 @@ var moduleUiFileTypes = {
1702
1714
  scalar: new Set(["Template", "Unit"])
1703
1715
  };
1704
1716
  var testFilePattern = /\.(test|spec)\.(ts|tsx)$/;
1705
- var createDependencyScanner = async (exec) => (await import("./dependencyScanner-shs82ynp.js")).TypeScriptDependencyScanner.from(exec);
1717
+ var createDependencyScanner = async (exec) => (await import("./dependencyScanner-0z2h2tks.js")).TypeScriptDependencyScanner.from(exec);
1706
1718
  var isAllowedTestFile = (filename) => testFilePattern.test(filename);
1707
1719
  var getScanPath = (exec, relativePath) => path7.posix.join(`${exec.type}s`, exec.name, relativePath.split(path7.sep).join("/"));
1708
1720
  async function clearGeneratedRootCapacitorConfigs(exec) {
@@ -2226,7 +2238,8 @@ var staticTemplateFileExtensions = new Set([
2226
2238
  ".woff2",
2227
2239
  ".xml"
2228
2240
  ]);
2229
- var formatCommandArg = (value) => /^[\w@%+=:,./-]+$/.test(value) ? value : JSON.stringify(value);
2241
+ var plainCommandArgPattern = process.platform === "win32" ? /^[\w@%+=:,./\\-]+$/ : /^[\w@%+=:,./-]+$/;
2242
+ var formatCommandArg = (value) => plainCommandArgPattern.test(value) ? value : JSON.stringify(value);
2230
2243
  var formatCommandForDisplay = (command, args = []) => [command, ...args].map(formatCommandArg).join(" ");
2231
2244
 
2232
2245
  class CommandExecutionError extends Error {
@@ -2580,7 +2593,7 @@ class Executor {
2580
2593
  const isDirectory = (await stat2(src)).isDirectory();
2581
2594
  if (!await FileSys.exists(dest) && isDirectory)
2582
2595
  await mkdir3(dest, { recursive: true });
2583
- if (dereference)
2596
+ if (dereference || process.platform === "win32")
2584
2597
  await cpEntry(src, dest, { recursive: isDirectory, dereference: true, force: true });
2585
2598
  else
2586
2599
  await $`cp -r ${src}${isDirectory ? "/." : ""} ${dest}`;
@@ -3289,14 +3302,20 @@ class AppExecutor extends SysExecutor {
3289
3302
  ...env
3290
3303
  };
3291
3304
  }
3305
+ async getDatabaseModeEnv() {
3306
+ const akanConfig = await this.getConfig();
3307
+ return {
3308
+ AKAN_DATABASE_MODE: akanConfig.resolveDatabaseMode(),
3309
+ AKAN_DATABASE_MODES: akanConfig.database.modes.join(",")
3310
+ };
3311
+ }
3292
3312
  async prepareCommand(type) {
3293
3313
  const akanConfig = await this.getConfig();
3294
- const databaseMode = process.env.AKAN_DATABASE_MODE ?? akanConfig.defaultDatabaseMode ?? "single";
3295
3314
  const routeEnv = {
3296
3315
  AKAN_PUBLIC_BASE_PATHS: [...akanConfig.basePaths].join(","),
3297
3316
  AKAN_PUBLIC_API_PREFIX: akanConfig.api.prefix,
3298
3317
  AKAN_PUBLIC_WS_PREFIX: akanConfig.api.websocketPrefix,
3299
- AKAN_DATABASE_MODE: databaseMode
3318
+ ...await this.getDatabaseModeEnv()
3300
3319
  };
3301
3320
  Object.assign(process.env, routeEnv);
3302
3321
  if (type === "build") {
@@ -3325,6 +3344,8 @@ class AppExecutor extends SysExecutor {
3325
3344
  const buildEnv = { ...env };
3326
3345
  delete buildEnv.AKAN_PUBLIC_CLIENT_PORT;
3327
3346
  delete buildEnv.AKAN_PUBLIC_SERVER_PORT;
3347
+ delete buildEnv.AKAN_PUBLIC_OPERATION_MODE;
3348
+ delete process.env.AKAN_PUBLIC_OPERATION_MODE;
3328
3349
  Object.assign(process.env, buildEnv);
3329
3350
  }
3330
3351
  return { env };
@@ -3372,7 +3393,9 @@ class AppExecutor extends SysExecutor {
3372
3393
  const owners = new Map;
3373
3394
  const devOnlyKeys = new Set;
3374
3395
  const devOnlyDirs = [];
3375
- for (const root of await this.getPageRoots()) {
3396
+ const pageRoots = await this.getPageRoots();
3397
+ const libKeyPrefixes = pageRoots.map((root) => root.keyPrefix).filter(Boolean);
3398
+ for (const root of pageRoots) {
3376
3399
  if (!await FileSys.dirExists(root.dir))
3377
3400
  continue;
3378
3401
  for await (const rel of glob.scan({
@@ -3384,6 +3407,8 @@ class AppExecutor extends SysExecutor {
3384
3407
  if (segments.some((s) => s === "node_modules"))
3385
3408
  continue;
3386
3409
  const posix = `${root.keyPrefix}${segments.join("/")}`;
3410
+ if (!root.keyPrefix && libKeyPrefixes.some((prefix) => posix.startsWith(prefix)))
3411
+ continue;
3387
3412
  const absPath = path8.join(root.dir, ...segments);
3388
3413
  validatePageSourceFile(posix, { filePath: absPath });
3389
3414
  if (!isRouteSourceFile(posix))
@@ -3473,7 +3498,8 @@ class AppExecutor extends SysExecutor {
3473
3498
  return entries.map((entry) => `${parent}${AppExecutor.#pageLibsDir}/${entry}/`);
3474
3499
  }))).flat();
3475
3500
  const wanted = parents.flatMap((parent) => libs.map((lib) => `${parent}${AppExecutor.#pageLibsDir}/(${lib})/`));
3476
- if (linked.sort().join(",") === wanted.sort().join(","))
3501
+ const isLink = async (key) => (await lstat(`${this.cwdPath}/page/${key.slice(0, -1)}`).catch(() => null))?.isSymbolicLink() ?? false;
3502
+ if (linked.sort().join(",") === wanted.sort().join(",") && (await Promise.all(linked.map(isLink))).every(Boolean))
3477
3503
  return false;
3478
3504
  await Promise.all(parents.map((parent) => this.removeDir(`${this.cwdPath}/page/${parent}${AppExecutor.#pageLibsDir}`)));
3479
3505
  for (const parent of parents) {
@@ -3781,4 +3807,4 @@ class ModuleExecutor extends Executor {
3781
3807
  }
3782
3808
  }
3783
3809
 
3784
- export { AGENT_BLOCK_START, AGENT_BLOCK_END, stampBlockVersion, extractBlockVersion, readDevkitVersion, upsertAgentBlock, extractAgentBlock, renderRecipeEntries, collectScopeRecipeSources, renderScopeAgentBlock, CLAUDE_COMMENT_RULE, AsyncDefaultExportDetector, resolveSsrPageEntriesForApp, CodegenLock, rootAllowedFiles, rootAllowedDirs, isAllowedLibFacetRootFile, isScannedRootEntry, AppInfo, Spinner, CommandExecutionError, Executor, WorkspaceExecutor, SysExecutor, AppExecutor, LibExecutor, PkgExecutor, ModuleExecutor };
3810
+ export { AGENT_BLOCK_START, AGENT_BLOCK_END, stampBlockVersion, extractBlockVersion, readDevkitVersion, upsertAgentBlock, extractAgentBlock, renderRecipeEntries, collectScopeRecipeSources, renderScopeAgentBlock, CLAUDE_COMMENT_RULE, AsyncDefaultExportDetector, resolveSsrPageEntriesForApp, CodegenLock, Linter, rootAllowedFiles, rootAllowedDirs, isAllowedLibFacetRootFile, isScannedRootEntry, AppInfo, Spinner, CommandExecutionError, Executor, WorkspaceExecutor, SysExecutor, AppExecutor, LibExecutor, PkgExecutor, ModuleExecutor };
@@ -4,19 +4,34 @@ class CodeAgentRpcHost2 {
4
4
  #agent;
5
5
  #write;
6
6
  #buffer = "";
7
+ #started = false;
8
+ #resolveShutdown = () => {};
9
+ shutdown = new Promise((resolve) => {
10
+ this.#resolveShutdown = resolve;
11
+ });
7
12
  constructor(agent, write = (line) => process.stdout.write(line)) {
8
13
  this.#agent = agent;
9
14
  this.#write = write;
10
15
  }
11
16
  async serve(input = process.stdin) {
12
- this.#agent.on((event) => this.#emit(event));
13
- this.#agent.announce();
17
+ this.start();
14
18
  const decoder = new TextDecoder;
15
19
  for await (const chunk of input)
16
- await this.#push(decoder.decode(chunk, { stream: true }));
20
+ await this.feed(decoder.decode(chunk, { stream: true }));
17
21
  await this.#agent.abort().catch(() => {});
18
22
  }
19
- async#push(text) {
23
+ start() {
24
+ if (this.#started)
25
+ return;
26
+ this.#started = true;
27
+ this.#agent.on((event) => this.#emit(event));
28
+ this.#agent.announce();
29
+ }
30
+ attach(write) {
31
+ this.#write = write;
32
+ this.#buffer = "";
33
+ }
34
+ async feed(text) {
20
35
  this.#buffer += text;
21
36
  let index = this.#buffer.indexOf(`
22
37
  `);
@@ -41,6 +56,8 @@ class CodeAgentRpcHost2 {
41
56
  } catch (error) {
42
57
  this.#reply({ type: "reply", id: request.id, ok: false, error: String(error) });
43
58
  }
59
+ if (request.command?.type === "shutdown")
60
+ this.#resolveShutdown();
44
61
  }
45
62
  async#run(command) {
46
63
  switch (command.type) {
@@ -70,11 +87,11 @@ class CodeAgentRpcHost2 {
70
87
  }
71
88
  }
72
89
  #emit(event) {
73
- this.#write(`${JSON.stringify({ type: "event", event })}
90
+ this.#write?.(`${JSON.stringify({ type: "event", event })}
74
91
  `);
75
92
  }
76
93
  #reply(reply) {
77
- this.#write(`${JSON.stringify(reply)}
94
+ this.#write?.(`${JSON.stringify(reply)}
78
95
  `);
79
96
  }
80
97
  }