@akanjs/cli 3.1.2-rc.3 → 3.2.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/.build-stamp +1 -1
  2. package/{CodeAgent-n2tkg59z.js → CodeAgent-h6g8dg3a.js} +2 -2
  3. package/{CodeTui-9wsdx7ap.js → CodeTui-n9gacepn.js} +1 -1
  4. package/README.ko.md +9 -0
  5. package/README.md +9 -0
  6. package/TunnelShare-k3ja4w9x.js +14 -0
  7. package/{agent.command-tffz6wdn.js → agent.command-2f657613.js} +19 -17
  8. package/akanCode.js +2 -2
  9. package/{application.command-7bkxbrsp.js → application.command-yb8v177e.js} +45 -22
  10. package/{applicationBuildRunner-s13x3zqb.js → applicationBuildRunner-sctcmkyx.js} +57 -17
  11. package/buildBatch.proc.js +7 -7
  12. package/{cloud.command-a792bc10.js → cloud.command-et06ja22.js} +35 -18
  13. package/cloud.script-s6rbrwer.js +30 -0
  14. package/{code.command-ma8dtzww.js → code.command-7m67c7zc.js} +6 -6
  15. package/commandManifest.json +1 -1
  16. package/{context.command-80a1qhps.js → context.command-569z0rqf.js} +20 -19
  17. package/context.runner-ms8v1rxy.js +29 -0
  18. package/{guideline.command-195g0h9a.js → guideline.command-gnv3e8p8.js} +2 -2
  19. package/guidelines/akanApi/akanApi.instruction.md +317 -0
  20. package/guidelines/conventions/rules/app.md +5 -5
  21. package/guidelines/conventions/rules/config.md +1 -1
  22. package/guidelines/conventions/rules/gates.md +10 -5
  23. package/guidelines/conventions/rules/page.md +4 -2
  24. package/guidelines/conventions/rules/server.md +2 -0
  25. package/guidelines/conventions/rules/style.md +3 -1
  26. package/guidelines/conventions/rules/ts.md +2 -1
  27. package/guidelines/cssRule/cssRule.instruction.md +3 -1
  28. package/guidelines/pageRule/pageRule.instruction.md +3 -0
  29. package/incrementalBuilder.proc.js +70 -14
  30. package/{index-tns543wd.js → index-0fb3cpbt.js} +3 -3
  31. package/{index-zbrwnmf1.js → index-1q1cjn8s.js} +21 -11
  32. package/{index-wrmq92vk.js → index-3wjbhj2n.js} +1 -1
  33. package/{index-361ex3rb.js → index-48d5qsj3.js} +4 -4
  34. package/{index-aayg4dqf.js → index-5w9my9qe.js} +8 -8
  35. package/{index-1h2jc0x3.js → index-6wpaq392.js} +61 -15
  36. package/{index-tp56652m.js → index-7xdpww43.js} +69 -12
  37. package/index-7y5yghjg.js +2969 -0
  38. package/{index-zttm13c3.js → index-8g7tdsk4.js} +249 -696
  39. package/{index-m02tdq8a.js → index-8pb9yvp8.js} +63 -21
  40. package/{index-gbp1q1b5.js → index-8ts9774g.js} +4 -4
  41. package/{index-9zy8479y.js → index-93ewzmp6.js} +43 -14
  42. package/{index-zdpte1pj.js → index-9tbgb4d8.js} +1 -1
  43. package/index-abgh0jve.js +126 -0
  44. package/{index-khk05tsf.js → index-aj3ehkcx.js} +1 -1
  45. package/{index-84h43kg6.js → index-d4n1wmrz.js} +37 -4
  46. package/{index-gr9thy79.js → index-drz9e84d.js} +22 -8
  47. package/{index-hapx5myy.js → index-e3vmjtph.js} +2 -2
  48. package/{index-k64mhwbw.js → index-eajbmk10.js} +2 -1
  49. package/{index-0j1t1h2b.js → index-ed6ea0qp.js} +1 -1
  50. package/{index-sjabnf7j.js → index-fjr4d6yd.js} +444 -368
  51. package/index-hqrkqxx2.js +176 -0
  52. package/{index-z7kbxdqg.js → index-jdamtr7e.js} +3 -3
  53. package/{index-scck6h6d.js → index-kpdv34rq.js} +4 -4
  54. package/{index-ppvqy5bc.js → index-ktb3wcqz.js} +73 -34
  55. package/{index-sveq36gh.js → index-mmym5xmb.js} +4 -2
  56. package/{index-y4kcmbt2.js → index-mqntfzv5.js} +2 -2
  57. package/{index-4am4dvmf.js → index-ny2k80mv.js} +15 -3
  58. package/index-p6hjwt2d.js +1668 -0
  59. package/{index-wwe9rsrx.js → index-r0a604h4.js} +12 -2
  60. package/{index-jb2sreps.js → index-rc5fvqj2.js} +18 -18
  61. package/{index-db2nqrad.js → index-ryrm5z2c.js} +71 -19
  62. package/{index-eft5c2mp.js → index-s2grpzef.js} +331 -27
  63. package/{index-g500c5j9.js → index-sr5da35e.js} +33 -10
  64. package/{index-defp4gmb.js → index-sy481q2x.js} +1 -1
  65. package/{index-j9d3mjx1.js → index-thckcabc.js} +2 -2
  66. package/{index-9z3egsmg.js → index-vkzfk7qt.js} +25 -23
  67. package/index-w639tvkd.js +166 -0
  68. package/index-ygdbn9jn.js +122 -0
  69. package/{index-sp0qsr7a.js → index-zpv14wpy.js} +3 -3
  70. package/{index-sx91nf4z.js → index-zxsygkda.js} +18 -9
  71. package/index.js +24 -23
  72. package/{library.command-63hgt9te.js → library.command-1gp5qe3r.js} +3 -3
  73. package/{localRegistry.command-343ksmn9.js → localRegistry.command-v3g21rex.js} +25 -16
  74. package/{module.command-2hce9m6k.js → module.command-4xz9he6h.js} +6 -6
  75. package/{package.command-96eheyvd.js → package.command-s7qpnn1g.js} +12 -3
  76. package/package.json +2 -2
  77. package/{page.command-gs6d841d.js → page.command-fan34c49.js} +3 -3
  78. package/{pipeline.command-wdfvdbfj.js → pipeline.command-ph4fnn9w.js} +2 -2
  79. package/{primitive.command-7tdj12wn.js → primitive.command-3fqh8emf.js} +7 -7
  80. package/{projectTypecheck-kqj1t6hb.js → projectTypecheck-vkb40hjc.js} +1 -1
  81. package/{quality.command-29bgarh1.js → quality.command-ecj6exsh.js} +15 -10
  82. package/{repair.command-yng4rf5d.js → repair.command-fe9jw719.js} +6 -6
  83. package/{scalar.command-1nk4329t.js → scalar.command-cnvfhk0n.js} +5 -5
  84. package/skills/akan-debug/SKILL.md +2 -1
  85. package/skills/akan-page/SKILL.md +30 -2
  86. package/skills/akan-service/SKILL.md +77 -1
  87. package/{subspace.command-5cehmcdd.js → subspace.command-yxtt3v3e.js} +8 -8
  88. package/templates/app/lib/___appName__/__appName__.abstract.md.template +6 -0
  89. package/templates/app/page/_index.tsx +4 -284
  90. package/templates/app/page/_layout.tsx +1 -26
  91. package/templates/app/page/styles.css.template +58 -318
  92. package/templates/appSample/page/_index.tsx +281 -0
  93. package/templates/appSample/page/_layout.tsx +55 -0
  94. package/templates/appSample/page/styles.css.template +327 -0
  95. package/templates/libRoot/lib/___libName__/__libName__.abstract.md.template +6 -0
  96. package/templates/workspaceRoot/package.json.template +1 -12
  97. package/{tunnel.command-yrd4atqy.js → tunnel.command-ggj38mqf.js} +7 -7
  98. package/{typeChecker-j2jdnqsr.js → typeChecker-s640r6c0.js} +1 -1
  99. package/typecheck.proc.js +1 -1
  100. package/{verify.command-kbq0fcg8.js → verify.command-w9ttxkdz.js} +16 -14
  101. package/{workflow.command-274qfa8z.js → workflow.command-ss8devj0.js} +12 -12
  102. package/{workspace.command-r6hgmawy.js → workspace.command-rw1p0xeq.js} +50 -38
  103. package/TunnelShare-6d7z36sr.js +0 -14
  104. package/cloud.script-t2n13gv6.js +0 -27
  105. package/context.runner-wxqb3qcy.js +0 -28
  106. package/index-j2dgmzbj.js +0 -1259
  107. package/index-p6x5b7hr.js +0 -839
  108. package/index-vzpnr12w.js +0 -65
  109. package/templates/workspaceRoot/patches/zod@3.25.76.patch.template +0 -22
  110. package/templates/workspaceRoot/patches/zod@4.4.3.patch.template +0 -11
  111. /package/templates/{app → appSample}/page/_overrides.tsx +0 -0
  112. /package/templates/{app → appSample}/public/fonts/Pretendard-Black.woff2 +0 -0
  113. /package/templates/{app → appSample}/public/fonts/Pretendard-Bold.woff2 +0 -0
  114. /package/templates/{app → appSample}/public/fonts/Pretendard-ExtraBold.woff2 +0 -0
  115. /package/templates/{app → appSample}/public/fonts/Pretendard-ExtraLight.woff2 +0 -0
  116. /package/templates/{app → appSample}/public/fonts/Pretendard-Light.woff2 +0 -0
  117. /package/templates/{app → appSample}/public/fonts/Pretendard-Medium.woff2 +0 -0
  118. /package/templates/{app → appSample}/public/fonts/Pretendard-Regular.woff2 +0 -0
  119. /package/templates/{app → appSample}/public/fonts/Pretendard-SemiBold.woff2 +0 -0
  120. /package/templates/{app → appSample}/public/fonts/Pretendard-Thin.woff2 +0 -0
  121. /package/templates/{app → appSample}/public/jelly/cloud.webp +0 -0
  122. /package/templates/{app → appSample}/public/jelly/comet.webp +0 -0
  123. /package/templates/{app → appSample}/public/jelly/moon.webp +0 -0
  124. /package/templates/{app → appSample}/public/jelly/planet.webp +0 -0
  125. /package/templates/{app → appSample}/public/jelly/rocket.webp +0 -0
  126. /package/templates/{app → appSample}/public/jelly/star.webp +0 -0
  127. /package/templates/{app → appSample}/public/jelly/sugar.webp +0 -0
  128. /package/templates/{app → appSample}/public/logo.png +0 -0
  129. /package/templates/{app → appSample}/ui/Recipe/index.ts +0 -0
  130. /package/templates/{app → appSample}/ui/Recipe/jellyButton.ts +0 -0
@@ -2,14 +2,14 @@
2
2
  import {
3
3
  AppExecutor,
4
4
  LibExecutor
5
- } from "./index-g500c5j9.js";
5
+ } from "./index-sr5da35e.js";
6
6
  import {
7
7
  createAst,
8
8
  AkanIndex
9
- } from "./index-j2dgmzbj.js";
9
+ } from "./index-7y5yghjg.js";
10
10
  import {
11
11
  camelToKebabCase
12
- } from "./index-9zy8479y.js";
12
+ } from "./index-93ewzmp6.js";
13
13
 
14
14
  // pkgs/@akanjs/devkit/workflow/artifacts.ts
15
15
  import { capitalize as capitalize2 } from "akanjs/common";
@@ -3394,28 +3394,70 @@ var inspectRenameKeyPlan = async (workspace, plan) => {
3394
3394
  predictedChanges: files.length ? files.map((file) => ({ target: file.path, action: "modify", applyScope: "auto", reason: file.reason })) : plan.predictedChanges
3395
3395
  };
3396
3396
  };
3397
- var inspectWorkflowPlan = async (workspace, plan) => {
3398
- if (plan.workflow === "rename-key")
3399
- return await inspectRenameKeyPlan(workspace, plan);
3400
- if (plan.workflow !== "add-mutation" && plan.workflow !== "create-interaction")
3401
- return plan;
3402
- const app = planString(plan.inputs, "app");
3397
+ var syssHolding = async (workspace, module, except) => {
3398
+ const [apps, libs] = await workspace.getSyss();
3399
+ const others = await Promise.all([...apps, ...libs].filter((name) => name !== except.name).map(async (name) => await resolveWorkflowSys(workspace, name)));
3400
+ const holding = await Promise.all(others.map(async (other) => other && (await other.readdir("lib")).includes(module) ? other : null));
3401
+ return holding.filter((other) => other !== null);
3402
+ };
3403
+ var moduleMissing = async (workspace, sys, module) => {
3404
+ if ((await sys.readdir("lib")).includes(module))
3405
+ return null;
3406
+ const root = getSysRoot(sys);
3407
+ const modules = [...await sys.getDatabaseModules(), ...await sys.getServiceModules()];
3408
+ const sameName = modules.find((name) => name.replace(/^_/, "").toLowerCase() === module.toLowerCase());
3409
+ const isScalar = (await sys.getScalarModules()).includes(module);
3410
+ const [holder] = sameName || isScalar ? [] : await syssHolding(workspace, module, sys);
3411
+ return {
3412
+ severity: "error",
3413
+ code: "workflow-module-missing",
3414
+ input: "module",
3415
+ message: [
3416
+ `No module named ${module} in ${root}: ${root}/lib/${module} does not exist.`,
3417
+ modules.length ? `Its modules are ${modules.join(", ")}.` : `${root} has no modules yet.`,
3418
+ sameName ? `Did you mean ${sameName}?` : isScalar ? `${root}/lib/__scalar/${module} is a scalar, and this workflow writes only into a module under ${root}/lib.` : holder ? `${module} is in ${getSysRoot(holder)}, so plan this with --app ${holder.name}.` : `If ${module} is a new model, create it with the create-module workflow first, then plan this again.`
3419
+ ].join(" ")
3420
+ };
3421
+ };
3422
+ var workflowTargetDiagnostics = async (workspace, spec, inputs) => {
3423
+ const app = planString(inputs, "app");
3403
3424
  if (!app)
3404
- return plan;
3425
+ return [];
3405
3426
  const sys = await resolveWorkflowSys(workspace, app).catch(() => null);
3406
- if (!sys)
3427
+ if (!sys) {
3428
+ const [apps, libs] = await workspace.getSyss();
3429
+ return [
3430
+ {
3431
+ severity: "error",
3432
+ code: "workflow-target-missing",
3433
+ input: "app",
3434
+ message: `No app or library named ${app}. Apps: ${apps.join(", ") || "none"}. Libraries: ${libs.join(", ") || "none"}.`
3435
+ }
3436
+ ];
3437
+ }
3438
+ const module = planString(inputs, "module");
3439
+ const moduleSpec = spec.inputs.module;
3440
+ if (!module || !moduleSpec?.mustExist)
3441
+ return [];
3442
+ const missing = await moduleMissing(workspace, sys, module);
3443
+ return missing ? [missing] : [];
3444
+ };
3445
+ var inspectWorkflowPlan = async (workspace, spec, plan) => {
3446
+ const targetDiagnostics = await workflowTargetDiagnostics(workspace, spec, plan.inputs);
3447
+ if (targetDiagnostics.length)
3407
3448
  return {
3408
3449
  ...plan,
3409
- diagnostics: [
3410
- ...plan.diagnostics,
3411
- {
3412
- severity: "error",
3413
- code: "workflow-target-missing",
3414
- input: "app",
3415
- message: `No app or library named ${app}.`
3416
- }
3417
- ]
3450
+ predictedChanges: [],
3451
+ diagnostics: [...plan.diagnostics, ...targetDiagnostics],
3452
+ recommendations: []
3418
3453
  };
3454
+ if (plan.workflow === "rename-key")
3455
+ return await inspectRenameKeyPlan(workspace, plan);
3456
+ if (plan.workflow !== "add-mutation" && plan.workflow !== "create-interaction")
3457
+ return plan;
3458
+ const sys = await resolveWorkflowSys(workspace, planString(plan.inputs, "app")).catch(() => null);
3459
+ if (!sys)
3460
+ return plan;
3419
3461
  const inspected = plan.workflow === "add-mutation" ? await MutationScaffold.build(sys, {
3420
3462
  module: planString(plan.inputs, "module"),
3421
3463
  mutation: planString(plan.inputs, "mutation"),
@@ -3760,4 +3802,4 @@ for (const candidate of toolingRolloutCandidates) {
3760
3802
  if (isRestrictedCandidate(candidate))
3761
3803
  restrictedCandidates.set(candidate.packageName, candidate);
3762
3804
  }
3763
- export { InteractionScaffold, jsonText, workflowStatus, compactDiagnostics, workflowPlanApproval, createWorkflowApplyReport, workflowCommandsForPlan, workflowPathsForPlan, workflowRunArtifactPath, writeWorkflowRunArtifact, workflowSyncDir, generatedFilePathsForTarget, writeGeneratedSyncState, readWorkflowRunArtifact, createWorkflowBaselineSummary, createWorkflowValidationRunReport, createDryRunWorkflowApplyReport, createRepairReport, sourceFile, moduleComponentName, moduleSourcePaths, generatedFilesForSync, validationCommandsForTarget, nextActionsForTarget, createPrimitiveWriteReport, createPassedPrimitiveReport, scalarChangedFiles, bilingualLabelForField, bilingualDescriptionForField, normalizeFieldType, ensureNamedImport, ensureBaseImport, ensureBaseTypeImport, coerceFieldDefault, fieldExpression, viaBuilderParameterName, insertIntoObject, insertLightProjectionField, insertTemplateField, ensureEnumImport, insertEnumClass, insertDictionaryModelField, hasConstantInputField, hasDictionaryModelField, ensureConstantTypeImport, insertDictionaryEnum, parseValues, hasSourceParseErrors, hasClassMethod, insertClassMethod, hasSignalFactoryEntry, insertSignalFactoryEntry, buildAkanModuleContextIndex, addFieldUiPolicyForType, createWorkflowStepRegistry, WorkflowExecutor, KeyRename, MutationScaffold, isWorkflowSysName, isWorkflowModuleName, listWorkflowSpecs, getWorkflowSpec, compactWorkflowInputs, createWorkflowPlan, inspectWorkflowPlan, renderWorkflowList, renderWorkflowExplain, renderWorkflowPlan, renderWorkflowApply, renderWorkflowValidation, renderRepairReport, renderWorkflowRunArtifact, renderPrimitiveReport, toolingRolloutGate };
3805
+ export { InteractionScaffold, jsonText, workflowStatus, compactDiagnostics, workflowPlanApproval, createWorkflowApplyReport, workflowCommandsForPlan, workflowPathsForPlan, workflowRunArtifactPath, writeWorkflowRunArtifact, workflowSyncDir, generatedFilePathsForTarget, writeGeneratedSyncState, readWorkflowRunArtifact, createWorkflowBaselineSummary, createWorkflowValidationRunReport, createDryRunWorkflowApplyReport, createRepairReport, sourceFile, moduleComponentName, moduleSourcePaths, generatedFilesForSync, validationCommandsForTarget, nextActionsForTarget, createPrimitiveWriteReport, createPassedPrimitiveReport, scalarChangedFiles, bilingualLabelForField, bilingualDescriptionForField, normalizeFieldType, ensureNamedImport, ensureBaseImport, ensureBaseTypeImport, coerceFieldDefault, fieldExpression, viaBuilderParameterName, insertIntoObject, insertLightProjectionField, insertTemplateField, ensureEnumImport, insertEnumClass, insertDictionaryModelField, hasConstantInputField, hasDictionaryModelField, ensureConstantTypeImport, insertDictionaryEnum, parseValues, hasSourceParseErrors, hasClassMethod, insertClassMethod, hasSignalFactoryEntry, insertSignalFactoryEntry, buildAkanModuleContextIndex, addFieldUiPolicyForType, createWorkflowStepRegistry, WorkflowExecutor, KeyRename, MutationScaffold, isWorkflowSysName, isWorkflowModuleName, listWorkflowSpecs, getWorkflowSpec, compactWorkflowInputs, createWorkflowPlan, workflowTargetDiagnostics, inspectWorkflowPlan, renderWorkflowList, renderWorkflowExplain, renderWorkflowPlan, renderWorkflowApply, renderWorkflowValidation, renderRepairReport, renderWorkflowRunArtifact, renderPrimitiveReport, toolingRolloutGate };
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-9zy8479y.js";
5
+ } from "./index-93ewzmp6.js";
6
6
  import {
7
7
  ModuleExecutor
8
- } from "./index-g500c5j9.js";
8
+ } from "./index-sr5da35e.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-m02tdq8a.js";
16
+ } from "./index-8pb9yvp8.js";
17
17
  import {
18
18
  PageScript
19
- } from "./index-khk05tsf.js";
19
+ } from "./index-aj3ehkcx.js";
20
20
  import {
21
21
  pluralizeName
22
22
  } from "./index-nz8prx9g.js";
@@ -10,7 +10,7 @@ import {
10
10
  LibExecutor,
11
11
  PkgExecutor,
12
12
  ModuleExecutor
13
- } from "./index-g500c5j9.js";
13
+ } from "./index-sr5da35e.js";
14
14
 
15
15
  // pkgs/@akanjs/devkit/commandDecorators/camelToKebabCase.ts
16
16
  var camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
@@ -538,8 +538,25 @@ var assertCurrentDirectoryIsWorkspaceRoot = async () => {
538
538
  ].join(`
539
539
  `));
540
540
  };
541
+ var shellWordOf = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
542
+ var rerunCommandOf = (argv, operands, slot) => (target) => {
543
+ const [commandName = "", ...words] = argv;
544
+ let at = 0;
545
+ for (const operand of operands.slice(0, slot))
546
+ if (typeof operand === "string")
547
+ at = words.indexOf(operand, at) + 1;
548
+ const given = operands[slot];
549
+ const givenAt = typeof given === "string" ? words.indexOf(given, at) : -1;
550
+ const rerun = words.map(shellWordOf);
551
+ if (givenAt >= 0)
552
+ rerun.splice(givenAt, 1, target);
553
+ else
554
+ rerun.splice(at, 0, target);
555
+ return ["akan", commandName, ...rerun].join(" ");
556
+ };
557
+ var rerunRemedyOf = (rerun, placeholder) => rerun ? { remedy: `rerun it as \`${rerun(placeholder)}\`` } : {};
541
558
  var parseAppNameList = (value) => (Array.isArray(value) ? value : value === undefined ? [] : [value]).flatMap((entry) => entry.split(",")).map((entry) => entry.trim()).filter(Boolean);
542
- var getAppsArgumentValue = async (value, workspace) => {
559
+ var getAppsArgumentValue = async (value, workspace, rerun) => {
543
560
  const appNames = await workspace.getApps();
544
561
  if (appNames.length === 0)
545
562
  throw new Error("No apps found in this workspace (apps/<appName>/akan.config.ts)");
@@ -554,7 +571,7 @@ var getAppsArgumentValue = async (value, workspace) => {
554
571
  }
555
572
  if (appNames.length === 1 && appNames[0])
556
573
  return [AppExecutor.from(workspace, appNames[0])];
557
- assertPromptable("Missing apps", { choices: [...appNames, "all"] });
574
+ assertPromptable("Missing apps", { choices: [...appNames, "all"], ...rerunRemedyOf(rerun, "<apps...>") });
558
575
  const remembered = new Set(await AppSelectionMemory.read(workspace.workspaceRoot));
559
576
  const picked = await checkbox({
560
577
  message: "Select the apps to run (space to toggle, enter to confirm)",
@@ -564,7 +581,7 @@ var getAppsArgumentValue = async (value, workspace) => {
564
581
  await AppSelectionMemory.write(workspace.workspaceRoot, picked);
565
582
  return picked.map((name) => AppExecutor.from(workspace, name));
566
583
  };
567
- var getInternalArgumentValue = async (argMeta, value, workspace) => {
584
+ var getInternalArgumentValue = async (argMeta, value, workspace, rerun) => {
568
585
  if (argMeta.type === "Workspace")
569
586
  return workspace;
570
587
  const sysType = argMeta.type.toLowerCase();
@@ -586,12 +603,18 @@ var getInternalArgumentValue = async (argMeta, value, workspace) => {
586
603
  return found;
587
604
  if (!value && argMeta.option?.onlyApp && appNames.length === 1 && appNames[0])
588
605
  return AppExecutor.from(workspace, appNames[0]);
589
- assertPromptable(problemOf(sysType === "exec" ? "app, lib or pkg" : "app or lib"), {
590
- choices: [...appNames, ...libNames, ...pkgChoices]
591
- });
606
+ const [kind, placeholder] = sysType === "exec" ? ["app, lib or pkg", "<app-lib-or-pkg>"] : ["app or lib", "<app-or-lib>"];
607
+ const choices = [...appNames, ...libNames, ...pkgChoices];
608
+ const only = choices.length === 1 ? execOf(choices[0] ?? "") : null;
609
+ if (!value && only && !process.stdin.isTTY) {
610
+ const how = rerun ? `: ${rerun(only.name)}` : "";
611
+ Logger.rawLog(`No ${kind} named, so this runs on '${only.name}', the only one in this workspace${how}`, undefined, "error");
612
+ return only;
613
+ }
614
+ assertPromptable(problemOf(kind), { choices, ...rerunRemedyOf(rerun, placeholder) });
592
615
  const name = await select({
593
616
  message: sysType === "exec" ? `Select the App or Lib or Pkg name` : `Select the App or Lib name`,
594
- choices: [...appNames, ...libNames, ...pkgChoices]
617
+ choices
595
618
  });
596
619
  const picked = execOf(name);
597
620
  if (!picked)
@@ -602,20 +625,20 @@ var getInternalArgumentValue = async (argMeta, value, workspace) => {
602
625
  return AppExecutor.from(workspace, value);
603
626
  if (!value && appNames.length === 1 && appNames[0])
604
627
  return AppExecutor.from(workspace, appNames[0]);
605
- assertPromptable(problemOf("app"), { choices: appNames });
628
+ assertPromptable(problemOf("app"), { choices: appNames, ...rerunRemedyOf(rerun, "<app>") });
606
629
  const appName = await select({ message: `Select the ${sysType} name`, choices: appNames });
607
630
  return AppExecutor.from(workspace, appName);
608
631
  } else if (sysType === "lib") {
609
632
  if (value && libNames.includes(value))
610
633
  return LibExecutor.from(workspace, value);
611
- assertPromptable(problemOf("lib"), { choices: libNames });
634
+ assertPromptable(problemOf("lib"), { choices: libNames, ...rerunRemedyOf(rerun, "<lib>") });
612
635
  const libName = await select({ message: `Select the ${sysType} name`, choices: libNames });
613
636
  return LibExecutor.from(workspace, libName);
614
637
  } else if (sysType === "pkg") {
615
638
  const pkgs = await workspace.getPkgs();
616
639
  if (value && pkgs.includes(value))
617
640
  return PkgExecutor.from(workspace, value);
618
- assertPromptable(problemOf("pkg"), { choices: pkgs });
641
+ assertPromptable(problemOf("pkg"), { choices: pkgs, ...rerunRemedyOf(rerun, "<pkg>") });
619
642
  const pkgName = await select({ message: `Select the ${sysType} name`, choices: pkgs });
620
643
  return PkgExecutor.from(workspace, pkgName);
621
644
  } else if (sysType === "module") {
@@ -638,7 +661,12 @@ var getInternalArgumentValue = async (argMeta, value, workspace) => {
638
661
  } else
639
662
  throw new Error(`Invalid system name: ${sysName}`);
640
663
  }
641
- assertPromptable(problemOf("module"));
664
+ const systems = [
665
+ ...appNames.map((name) => AppExecutor.from(workspace, name)),
666
+ ...libNames.map((name) => LibExecutor.from(workspace, name))
667
+ ];
668
+ const choices = process.stdin.isTTY ? [] : (await Promise.all(systems.map(async (sys) => (await sys.getModules()).map((m) => `${sys.name}:${m}`)))).flat();
669
+ assertPromptable(problemOf("module"), { choices, ...rerunRemedyOf(rerun, "<sys:module>") });
642
670
  const { type, name } = await select({
643
671
  message: `select the App or Lib name`,
644
672
  choices: [
@@ -745,14 +773,15 @@ ${versionWarning}`), undefined, "error");
745
773
  const workspace = WorkspaceExecutor.fromRoot();
746
774
  const commandContext = { values: {} };
747
775
  for (const argMeta of allArgMetas) {
776
+ const rerun = rerunCommandOf(process.argv.slice(2), cmdArgs, argMeta.idx);
748
777
  if (argMeta.type === "Option")
749
778
  commandArgs[argMeta.idx] = await getOptionValue(argMeta, opt, commandContext);
750
779
  else if (argMeta.type === "Argument")
751
780
  commandArgs[argMeta.idx] = await getArgumentValue(argMeta, cmdArgs[argMeta.idx]);
752
781
  else if (argMeta.type === "Apps")
753
- commandArgs[argMeta.idx] = await getAppsArgumentValue(cmdArgs[argMeta.idx], workspace);
782
+ commandArgs[argMeta.idx] = await getAppsArgumentValue(cmdArgs[argMeta.idx], workspace, rerun);
754
783
  else
755
- commandArgs[argMeta.idx] = await getInternalArgumentValue(argMeta, cmdArgs[argMeta.idx], workspace);
784
+ commandArgs[argMeta.idx] = await getInternalArgumentValue(argMeta, cmdArgs[argMeta.idx], workspace, rerun);
756
785
  if (commandArgs[argMeta.idx] instanceof AppExecutor)
757
786
  process.env.AKAN_PUBLIC_APP_NAME = commandArgs[argMeta.idx].name;
758
787
  else if (Array.isArray(commandArgs[argMeta.idx])) {
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  GlobalConfig,
4
4
  CloudApi
5
- } from "./index-gr9thy79.js";
5
+ } from "./index-drz9e84d.js";
6
6
 
7
7
  // pkgs/@akanjs/cli/tunnel/TunnelShare.ts
8
8
  import { TunnelAgent } from "akanjs/server/tunnel";
@@ -0,0 +1,126 @@
1
+ // @bun
2
+ import {
3
+ FrameworkMapBuilder,
4
+ FrameworkMapDoc
5
+ } from "./index-7y5yghjg.js";
6
+
7
+ // pkgs/@akanjs/devkit/frameworkGraph.ts
8
+ import { readdir, readFile, realpath, stat } from "fs/promises";
9
+ import path from "path";
10
+ import ts from "typescript";
11
+ var packageSpecs = [
12
+ { name: "akanjs", split: true },
13
+ { name: "@akanjs/devkit", split: false }
14
+ ];
15
+ var channelSpecs = [
16
+ { file: "service/ipcTypes.ts", union: "AkanIpcMessage", label: "gateway \u21C4 child" },
17
+ { file: "server/artifact/ipcTypes.ts", union: "BuilderMessage", label: "dev host \u21C4 builder, relayed to the child" },
18
+ { file: "server/rscWorker.tsx", union: "InMsg", label: "server \u2192 RSC worker" },
19
+ { file: "server/rscWorkerHost.ts", union: "RscInMsg", label: "RSC worker \u2192 server" },
20
+ { file: "server/hmr/wsHub.ts", union: "HmrMessage", label: "dev server \u2192 browser tab", relays: ["HmrWsHub"] }
21
+ ];
22
+ var skippedDirs = new Set(["node_modules", "vendor", "types", "integration", "csrE2e", "platformTest"]);
23
+
24
+ class FrameworkGraph {
25
+ static architectureFile = "pkgs/akanjs/ARCHITECTURE.md";
26
+ static #cache = new Map;
27
+ static #edits = new Map;
28
+ static async packagesOf(workspaceRoot) {
29
+ const found = await Promise.all(packageSpecs.map(async ({ name, split }) => {
30
+ const root = await FrameworkGraph.#isDir(path.join(workspaceRoot, "pkgs", name)) ? `pkgs/${name}` : await FrameworkGraph.#installedRoot(workspaceRoot, name);
31
+ return root ? [{ name, root, split }] : [];
32
+ }));
33
+ return found.flat();
34
+ }
35
+ static async build(workspaceRoot) {
36
+ const packages = await FrameworkGraph.packagesOf(workspaceRoot);
37
+ const akanjs = packages.find(({ name }) => name === "akanjs");
38
+ if (!akanjs)
39
+ return null;
40
+ const files = (await Promise.all(packages.map(({ root }) => FrameworkGraph.#filesUnder(workspaceRoot, root)))).flat();
41
+ const texts = await Promise.all(files.map(async (file) => [file, await readFile(path.join(workspaceRoot, file), "utf8")]));
42
+ return new FrameworkMapBuilder({
43
+ ts,
44
+ packages,
45
+ files: texts,
46
+ channels: channelSpecs.map((spec) => ({ ...spec, file: `${akanjs.root}/${spec.file}` }))
47
+ }).build();
48
+ }
49
+ static async architecture(workspaceRoot) {
50
+ const file = path.join(workspaceRoot, FrameworkGraph.architectureFile);
51
+ const current = await readFile(file, "utf8").then((text) => text.replace(/\r\n/g, `
52
+ `)).catch(() => null);
53
+ const map = current === null ? null : await FrameworkGraph.build(workspaceRoot);
54
+ if (current === null || !map || map.packages.find(({ name }) => name === "akanjs")?.root !== "pkgs/akanjs")
55
+ return null;
56
+ const next = FrameworkMapDoc.splice(current, FrameworkMapDoc.render(map, path.posix.dirname(FrameworkGraph.architectureFile)));
57
+ return {
58
+ file,
59
+ current,
60
+ next,
61
+ unknownClasses: FrameworkMapDoc.unknownClasses(next, map),
62
+ map
63
+ };
64
+ }
65
+ static touched(workspaceRoot, files) {
66
+ const roots = packageSpecs.map(({ name }) => path.join(workspaceRoot, "pkgs", name) + path.sep);
67
+ if (files.some((file) => roots.some((root) => path.resolve(workspaceRoot, file).startsWith(root))))
68
+ FrameworkGraph.#edits.set(workspaceRoot, (FrameworkGraph.#edits.get(workspaceRoot) ?? 0) + 1);
69
+ }
70
+ static async cached(workspaceRoot) {
71
+ const packages = await FrameworkGraph.packagesOf(workspaceRoot);
72
+ const stamps = await Promise.all(packages.map(async ({ name, root }) => root.startsWith("pkgs/") ? `${name}#${FrameworkGraph.#edits.get(workspaceRoot) ?? 0}` : `${name}@${await FrameworkGraph.#versionOf(path.join(workspaceRoot, root))}`));
73
+ const cacheKey = [workspaceRoot, ...stamps].join(`
74
+ `);
75
+ const existing = FrameworkGraph.#cache.get(cacheKey);
76
+ if (existing)
77
+ return await existing;
78
+ const built = FrameworkGraph.build(workspaceRoot);
79
+ built.catch(() => FrameworkGraph.#cache.delete(cacheKey));
80
+ FrameworkGraph.#cache.clear();
81
+ FrameworkGraph.#cache.set(cacheKey, built);
82
+ return await built;
83
+ }
84
+ static async#installedRoot(workspaceRoot, name) {
85
+ if (!await FrameworkGraph.#isDir(path.join(workspaceRoot, "node_modules")))
86
+ return null;
87
+ const resolved = await (async () => {
88
+ try {
89
+ return path.dirname(await realpath(Bun.resolveSync(`${name}/package.json`, workspaceRoot)));
90
+ } catch {
91
+ const dir = path.join(workspaceRoot, "node_modules", name);
92
+ return await FrameworkGraph.#isDir(dir) ? await realpath(dir) : null;
93
+ }
94
+ })();
95
+ if (!resolved)
96
+ return null;
97
+ const root = path.relative(await realpath(workspaceRoot), resolved).split(path.sep).join("/");
98
+ return root && !root.startsWith("..") && !path.isAbsolute(root) ? root : null;
99
+ }
100
+ static async#versionOf(dir) {
101
+ return await readFile(path.join(dir, "package.json"), "utf8").then((text) => JSON.parse(text).version ?? "").catch(() => "");
102
+ }
103
+ static async#isDir(dir) {
104
+ return await stat(dir).then((info) => info.isDirectory()).catch(() => false);
105
+ }
106
+ static async#filesUnder(workspaceRoot, root) {
107
+ const entries = await readdir(path.join(workspaceRoot, root), { withFileTypes: true });
108
+ const files = [];
109
+ for (const entry of entries) {
110
+ if (entry.name.startsWith(".") || skippedDirs.has(entry.name))
111
+ continue;
112
+ if (entry.isFile())
113
+ files.push(`${root}/${entry.name}`);
114
+ else if (entry.isDirectory()) {
115
+ for await (const file of new Bun.Glob("**/*.{ts,tsx}").scan({
116
+ cwd: path.join(workspaceRoot, root, entry.name)
117
+ }))
118
+ if (!file.split(path.sep).includes("node_modules"))
119
+ files.push(`${root}/${entry.name}/${file.split(path.sep).join("/")}`);
120
+ }
121
+ }
122
+ return files.filter((file) => FrameworkMapBuilder.isSourcePath(file)).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
123
+ }
124
+ }
125
+
126
+ export { FrameworkGraph };
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-9zy8479y.js";
5
+ } from "./index-93ewzmp6.js";
6
6
 
7
7
  // pkgs/@akanjs/cli/page/page.runner.ts
8
8
  class PageRunner extends runner("page") {
@@ -2,16 +2,22 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-9zy8479y.js";
5
+ } from "./index-93ewzmp6.js";
6
6
  import {
7
7
  FileSys2
8
8
  } from "./index-bns3wcpc.js";
9
9
  import {
10
10
  PkgExecutor
11
- } from "./index-g500c5j9.js";
11
+ } from "./index-sr5da35e.js";
12
12
  import {
13
13
  TypeScriptDependencyScanner2
14
14
  } from "./index-qd7xn2bk.js";
15
+ import {
16
+ FrameworkGraph
17
+ } from "./index-abgh0jve.js";
18
+ import {
19
+ MaintainabilityBaseline
20
+ } from "./index-hqrkqxx2.js";
15
21
 
16
22
  // pkgs/@akanjs/cli/package/package.runner.ts
17
23
  import path2 from "path";
@@ -213,7 +219,7 @@ class PackageRunner extends runner("package") {
213
219
  });
214
220
  } else {
215
221
  await pkg.dist.cp(pkg.cwdPath, pkg.dist.cwdPath);
216
- await $`rm -rf ${pkg.dist.cwdPath}/local`;
222
+ await $`rm -rf ${pkg.dist.cwdPath}/local ${pkg.dist.cwdPath}/akan.baseline.json`;
217
223
  await Promise.all([
218
224
  pkg.generateDistPackageJson(packageRuntimeDeps, packageRuntimeDevDeps),
219
225
  pkg.generateTsconfigJson()
@@ -331,9 +337,13 @@ class PackageRunner extends runner("package") {
331
337
  cwd: pkg.workspace.workspaceRoot
332
338
  });
333
339
  const [packResult] = JSON.parse(packOutput);
334
- const localFiles = (packResult?.files ?? []).filter((file) => file.path?.startsWith("local/"));
340
+ const packedPaths = (packResult?.files ?? []).map((file) => file.path ?? "");
341
+ const localFiles = packedPaths.filter((filePath) => filePath.startsWith("local/"));
335
342
  if (localFiles.length > 0)
336
343
  throw new Error(`[package] ${pkg.name} would publish ${localFiles.length} test-run files under local/`);
344
+ const baselines = packedPaths.filter((filePath) => path2.posix.basename(filePath) === MaintainabilityBaseline.fileName);
345
+ if (baselines.length > 0)
346
+ throw new Error(`[package] ${pkg.name} would publish its workspace's lint baseline: ${baselines.join(", ")}`);
337
347
  return {
338
348
  name: pkg.name,
339
349
  version: pkgJson.version,
@@ -341,6 +351,24 @@ class PackageRunner extends runner("package") {
341
351
  size: packResult?.size ?? 0
342
352
  };
343
353
  }
354
+ async syncArchitecture(workspace) {
355
+ const architecture = await FrameworkGraph.architecture(workspace.workspaceRoot);
356
+ if (!architecture)
357
+ throw new Error(`${FrameworkGraph.architectureFile} is only kept in the akanjs repository`);
358
+ const { file, current, next, unknownClasses, map } = architecture;
359
+ if (next !== current)
360
+ await Bun.write(file, next);
361
+ const problems = [
362
+ ...unknownClasses.map((name) => `\`${name}\` is cited outside the generated part but is no framework class`),
363
+ ...map.missing.map((channel) => `channel ${channel} was not found`),
364
+ ...map.cycles.map((cycle) => `facets ${cycle.join(", ")} load values from each other`)
365
+ ];
366
+ if (problems.length)
367
+ throw new Error(`${FrameworkGraph.architectureFile}:
368
+ ${problems.join(`
369
+ `)}`);
370
+ return { file: FrameworkGraph.architectureFile, changed: next !== current };
371
+ }
344
372
  async verifyAkanPublishPackages(workspace) {
345
373
  const pkgs = PackageRunner.publishableAkanPackages.map((pkgName) => PkgExecutor.from(workspace, pkgName));
346
374
  const peerExportsMaps = new Map;
@@ -403,6 +431,11 @@ class PackageScript extends script("package", [PackageRunner]) {
403
431
  spinner.succeed(`Package verified (${result.files} files, ${result.size} bytes packed)`);
404
432
  return result;
405
433
  }
434
+ async syncArchitecture(workspace) {
435
+ const spinner = workspace.spinning("Mapping the framework...");
436
+ const { file, changed } = await this.packageRunner.syncArchitecture(workspace);
437
+ spinner.succeed(changed ? `${file} regenerated` : `${file} is current`);
438
+ }
406
439
  async verifyAkanPublishPackages(workspace) {
407
440
  const spinner = workspace.spinning("Verifying Akan publish packages...");
408
441
  const results = await this.packageRunner.verifyAkanPublishPackages(workspace);
@@ -9,10 +9,10 @@ import {
9
9
  UpdatePackFolder,
10
10
  NativePublicEnv,
11
11
  NativeApp
12
- } from "./index-sp0qsr7a.js";
12
+ } from "./index-zpv14wpy.js";
13
13
  import {
14
14
  ExitCodeError
15
- } from "./index-9zy8479y.js";
15
+ } from "./index-93ewzmp6.js";
16
16
  import {
17
17
  ConfigLock
18
18
  } from "./index-bqbf654f.js";
@@ -193,21 +193,31 @@ class GlobalConfig {
193
193
  testTargets: { ...akanConfig.testTargets, ...testTargets }
194
194
  }));
195
195
  }
196
+ static #refreshMarginMs = 60 * 60000;
196
197
  static needRefreshToken(accessToken) {
197
- return !!accessToken?.expiresAt?.isBefore(dayjs().add(1, "hour"));
198
+ const { expiresAt, issuedAt } = accessToken;
199
+ if (!expiresAt)
200
+ return false;
201
+ const lifetimeMs = issuedAt?.isValid() ? expiresAt.diff(issuedAt) : Number.POSITIVE_INFINITY;
202
+ return expiresAt.isBefore(dayjs().add(Math.min(GlobalConfig.#refreshMarginMs, lifetimeMs / 2), "ms"));
203
+ }
204
+ static isExpired(accessToken) {
205
+ return !!accessToken.expiresAt && !accessToken.expiresAt.isAfter(dayjs());
198
206
  }
199
207
  static toAccessToken(accessToken) {
200
208
  return {
201
209
  jwt: accessToken.jwt,
202
210
  refreshToken: accessToken.refreshToken ?? null,
203
- expiresAt: accessToken.expiresAt ? dayjs(accessToken.expiresAt) : null
211
+ expiresAt: accessToken.expiresAt ? dayjs(accessToken.expiresAt) : null,
212
+ ...accessToken.issuedAt ? { issuedAt: dayjs(accessToken.issuedAt) } : {}
204
213
  };
205
214
  }
206
215
  static toAccessTokenDto(accessToken) {
207
216
  return {
208
217
  jwt: accessToken.jwt,
209
218
  refreshToken: accessToken.refreshToken ?? null,
210
- expiresAt: accessToken.expiresAt?.toString() ?? null
219
+ expiresAt: accessToken.expiresAt?.toString() ?? null,
220
+ ...accessToken.issuedAt ? { issuedAt: accessToken.issuedAt.toString() } : {}
211
221
  };
212
222
  }
213
223
  static toHostConfigDto(hostConfig) {
@@ -303,7 +313,7 @@ class CloudApi {
303
313
  const accessToken = hostConfig.auth?.accessToken;
304
314
  if (!accessToken || !GlobalConfig.needRefreshToken(accessToken))
305
315
  return new CloudApi(workspace, hostConfig);
306
- const tokenless = new CloudApi(workspace, hostConfig);
316
+ const tokenless = new CloudApi(workspace, { host: hostConfig.host });
307
317
  const refreshed = await GlobalConfig.refreshHostAuth(hostConfig.host, (refreshToken) => tokenless.refreshAuthToken(refreshToken));
308
318
  return new CloudApi(workspace, refreshed);
309
319
  }
@@ -313,11 +323,15 @@ class CloudApi {
313
323
  this.host = hostConfig.host;
314
324
  this.url = `${this.host}/api`;
315
325
  this.#api = new HttpClient(this.url);
316
- if (this.#accessToken && !GlobalConfig.needRefreshToken(this.#accessToken))
326
+ if (this.#accessToken && !GlobalConfig.isExpired(this.#accessToken))
317
327
  this.#api.setHeaders({ Authorization: `Bearer ${this.#accessToken.jwt}` });
318
328
  }
329
+ get needsSignIn() {
330
+ const accessToken = this.#accessToken;
331
+ return !!accessToken && !accessToken.refreshToken && GlobalConfig.needRefreshToken(accessToken);
332
+ }
319
333
  #authorize(accessTokenDto) {
320
- this.#accessToken = GlobalConfig.toAccessToken(accessTokenDto);
334
+ this.#accessToken = GlobalConfig.toAccessToken({ ...accessTokenDto, issuedAt: new Date().toISOString() });
321
335
  this.#api.setHeaders({ Authorization: `Bearer ${this.#accessToken.jwt}` });
322
336
  return this.#accessToken;
323
337
  }
@@ -2,12 +2,12 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-9zy8479y.js";
5
+ } from "./index-93ewzmp6.js";
6
6
  import {
7
7
  generatedFilesForSync,
8
8
  createPassedPrimitiveReport,
9
9
  scalarChangedFiles
10
- } from "./index-m02tdq8a.js";
10
+ } from "./index-8pb9yvp8.js";
11
11
  import {
12
12
  pluralizeName
13
13
  } from "./index-nz8prx9g.js";
@@ -11,7 +11,8 @@ var moduleInput = {
11
11
  module: {
12
12
  type: "string",
13
13
  required: true,
14
- description: "Target domain, service, or scalar module name."
14
+ description: "Target domain, service, or scalar module name.",
15
+ mustExist: true
15
16
  }
16
17
  };
17
18
  var baseValidation = [
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  DesktopBin
4
- } from "./index-sp0qsr7a.js";
4
+ } from "./index-zpv14wpy.js";
5
5
  // pkgs/@akanjs/devkit/mobile/desktopServerStage.ts
6
6
  import { cp, mkdir, readdir, rm, writeFile } from "fs/promises";
7
7
  import path from "path";