@akanjs/cli 3.1.1 → 3.1.2-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 (113) hide show
  1. package/.build-stamp +1 -1
  2. package/CodeAgent-dyc45f5w.js +11 -0
  3. package/{CodeAgentRpcHost-9g27hmer.js → CodeAgentRpcHost-6dzfkvsc.js} +1 -1
  4. package/CodeAgentRpcListener-tcwrdvst.js +182 -0
  5. package/{CodeTui-h6yz2kvq.js → CodeTui-q55b2zrn.js} +25 -8
  6. package/TunnelShare-hdq9h1hr.js +14 -0
  7. package/{agent.command-3r4jsck8.js → agent.command-20zaqe60.js} +18 -15
  8. package/akanCode.js +8 -7
  9. package/{application.command-g7xv6ad0.js → application.command-nd0fshsk.js} +11 -11
  10. package/{applicationBuildRunner-qvjnhr9j.js → applicationBuildRunner-s13x3zqb.js} +10 -9
  11. package/buildBatch.proc.js +6 -6
  12. package/{cloud.command-6ebygmhw.js → cloud.command-8kbddsz9.js} +25 -18
  13. package/cloud.script-hgvvajm3.js +27 -0
  14. package/code.command-625bg8s8.js +345 -0
  15. package/{context.command-svdh6b2w.js → context.command-p6haqjay.js} +19 -18
  16. package/context.runner-rsnqnk9j.js +27 -0
  17. package/{dependencyScanner-3afj2vt1.js → dependencyScanner-78sq8m4q.js} +2 -2
  18. package/{fileSys-wzzrntkw.js → fileSys-zpvt5gtf.js} +1 -1
  19. package/{guideline.command-qwp3tnjx.js → guideline.command-195g0h9a.js} +4 -4
  20. package/guidelines/agentRule/agentRule.instruction.md +22 -8
  21. package/guidelines/conventions/rules/auth.md +5 -4
  22. package/guidelines/conventions/rules/config.md +5 -1
  23. package/guidelines/conventions/rules/gates.md +2 -1
  24. package/guidelines/conventions/rules/module.md +1 -1
  25. package/guidelines/conventions/rules/server.md +8 -3
  26. package/guidelines/conventions/rules/ssr.md +2 -2
  27. package/guidelines/conventions/rules/tsx.md +2 -1
  28. package/guidelines/pageRule/pageRule.instruction.md +4 -4
  29. package/guidelines/runtimeRule/runtimeRule.instruction.md +35 -25
  30. package/guidelines/ssrRule/ssrRule.instruction.md +11 -10
  31. package/guidelines/transportRule/transportRule.instruction.md +5 -4
  32. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +1 -1
  33. package/incrementalBuilder.proc.js +4 -4
  34. package/{index-w4k2ragk.js → index-00a7j05x.js} +7 -7
  35. package/{index-w7q6h97v.js → index-0j1t1h2b.js} +3 -1
  36. package/{index-payhwt51.js → index-1h2jc0x3.js} +141 -67
  37. package/{index-vxmy1p4f.js → index-1qsd8ft1.js} +63 -123
  38. package/{index-s6da8ta9.js → index-2mwjshz5.js} +158 -51
  39. package/index-2nxk8wgs.js +266 -0
  40. package/{index-k5jbcxyh.js → index-2phm56a1.js} +49 -8
  41. package/{index-jje9qzyq.js → index-35j83zkd.js} +37 -3
  42. package/{index-m5n3ka0p.js → index-4am4dvmf.js} +13 -2
  43. package/index-75y7bcz4.js +28 -0
  44. package/{index-b8c289dx.js → index-7apsdr5g.js} +55 -12
  45. package/{index-8559hsz4.js → index-84h43kg6.js} +6 -5
  46. package/{index-eja64h28.js → index-9zy8479y.js} +5 -3
  47. package/{index-96wzdhfh.js → index-a1vb3x7t.js} +209 -36
  48. package/{index-52w0fvh8.js → index-bns3wcpc.js} +15 -0
  49. package/{index-am36s3jh.js → index-cjmjvg4r.js} +157 -117
  50. package/{index-1p0qbq3m.js → index-defp4gmb.js} +1 -1
  51. package/{index-4pdts00b.js → index-ewbmfarf.js} +10 -8
  52. package/{index-9rvcs76p.js → index-fhw7yq2d.js} +10 -10
  53. package/{index-8scw1pjk.js → index-g500c5j9.js} +178 -82
  54. package/{index-qxzrp5xt.js → index-g841cap9.js} +4 -4
  55. package/{index-qkkdhjm6.js → index-gr9thy79.js} +5 -5
  56. package/{index-4pf8g7ff.js → index-h7hehkw6.js} +3 -0
  57. package/{index-4mj92tsh.js → index-hm0tn7qv.js} +73 -68
  58. package/{index-r2wedvqn.js → index-j6eeh5d7.js} +1 -1
  59. package/{index-tgt2fnd6.js → index-j7hwy56s.js} +3 -3
  60. package/{index-rnphv731.js → index-jc2zbwra.js} +2 -2
  61. package/{index-z4b84y6k.js → index-khk05tsf.js} +1 -1
  62. package/{index-tvehn2sp.js → index-qd7xn2bk.js} +1 -1
  63. package/{index-266dewjs.js → index-qw6814m4.js} +53 -15
  64. package/{index-zcf6k8a5.js → index-raz588b3.js} +47 -12
  65. package/{index-at7bz0xq.js → index-s4nvxpzm.js} +2 -0
  66. package/{index-3yz30c07.js → index-sp0qsr7a.js} +114 -12
  67. package/{index-1shvxzt0.js → index-sveq36gh.js} +39 -42
  68. package/{index-r2w2eh93.js → index-t1t9wq9a.js} +4 -4
  69. package/index-t78230d7.js +191 -0
  70. package/{index-r0k3ham2.js → index-tgqameyb.js} +4 -4
  71. package/{index-dd44g6vz.js → index-tp56652m.js} +5 -5
  72. package/index-w15mg3km.js +389 -0
  73. package/{index-xq543a5y.js → index-y4kcmbt2.js} +2 -2
  74. package/index-yf9wc28h.js +52 -0
  75. package/{index-xqgwjz7a.js → index-zbrwnmf1.js} +9 -7
  76. package/{index-xxfy1jp2.js → index-zttm13c3.js} +4 -4
  77. package/index.js +24 -24
  78. package/{library.command-2853y6mk.js → library.command-63hgt9te.js} +4 -4
  79. package/{localRegistry.command-76ds31p4.js → localRegistry.command-g3f8k25t.js} +43 -23
  80. package/{module.command-yfnb0abs.js → module.command-r4sa2khp.js} +7 -6
  81. package/{package.command-d9s86hp9.js → package.command-96eheyvd.js} +5 -5
  82. package/package.json +2 -2
  83. package/{page.command-6a8a8rd1.js → page.command-gs6d841d.js} +4 -4
  84. package/{pipeline.command-rt3rwd2z.js → pipeline.command-wdfvdbfj.js} +3 -3
  85. package/{primitive.command-emcebgrq.js → primitive.command-dfsv4mpe.js} +8 -7
  86. package/{projectTypecheck-51m7eh1f.js → projectTypecheck-kqj1t6hb.js} +1 -1
  87. package/{prompter-hgcta8pb.js → prompter-qrwx1p17.js} +2 -2
  88. package/{quality.command-xtrk0n3x.js → quality.command-webzxee2.js} +6 -4
  89. package/{repair.command-51szxnxx.js → repair.command-3r3j1xre.js} +7 -6
  90. package/{scalar.command-8qv27t82.js → scalar.command-e8y47j6d.js} +6 -5
  91. package/skills/akan-agent/SKILL.md +8 -1
  92. package/skills/akan-code/SKILL.md +37 -11
  93. package/skills/akan-debug/SKILL.md +2 -1
  94. package/skills/akan-err/SKILL.md +2 -1
  95. package/skills/akan-query/SKILL.md +3 -2
  96. package/skills/akan-runtime/SKILL.md +3 -0
  97. package/{subspace.command-pn56pnh8.js → subspace.command-a1sf9n5a.js} +12 -10
  98. package/templates/appSample/lib/task/task.signal.ts +14 -9
  99. package/templates/appSample/srvkit/guards.ts +11 -0
  100. package/templates/service/__model__.dictionary.ts +3 -5
  101. package/templates/workspaceRoot/.gitignore.template +1 -0
  102. package/{tunnel.command-q2h0j2en.js → tunnel.command-dcb0wg93.js} +25 -13
  103. package/{verify.command-z1dsbmrt.js → verify.command-yyepccbh.js} +13 -11
  104. package/{workflow.command-r3y67jeq.js → workflow.command-z5pg9ay0.js} +12 -11
  105. package/{workspace.command-t2f0xsrw.js → workspace.command-d7x5jttw.js} +74 -47
  106. package/CodeAgent-35wnb7w5.js +0 -9
  107. package/CodeAgentRpcListener-7p7z5dd7.js +0 -97
  108. package/TunnelShare-xyjpa7gx.js +0 -14
  109. package/cloud.script-0s1jybd5.js +0 -26
  110. package/code.command-mpkm2emr.js +0 -167
  111. package/context.runner-ch0z3a8g.js +0 -26
  112. package/index-c6eggbee.js +0 -123
  113. package/index-ksfgqq1x.js +0 -49
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  camelToKebabCase,
4
4
  runner
5
- } from "./index-eja64h28.js";
5
+ } from "./index-9zy8479y.js";
6
6
  import {
7
7
  FileSys2
8
- } from "./index-52w0fvh8.js";
8
+ } from "./index-bns3wcpc.js";
9
9
  import {
10
10
  extractAgentBlock,
11
11
  collectScopeRecipeSources,
@@ -21,27 +21,32 @@ import {
21
21
  WorkspaceExecutor,
22
22
  SysExecutor,
23
23
  LibExecutor
24
- } from "./index-8scw1pjk.js";
24
+ } from "./index-g500c5j9.js";
25
25
  import {
26
26
  countBlocking,
27
27
  formatStyleContract,
28
28
  ThemeValidator
29
29
  } from "./index-62md4dwy.js";
30
+ import {
31
+ createAst,
32
+ createFactReader
33
+ } from "./index-2nxk8wgs.js";
30
34
  import {
31
35
  collectRecipeSources2,
32
36
  scanRecipes2
33
37
  } from "./index-hj6w4ka1.js";
38
+ import {
39
+ getNpmRegistryUrl,
40
+ getLatestPackageVersion
41
+ } from "./index-4am4dvmf.js";
34
42
  import {
35
43
  sysInputs,
36
44
  workflowSpecs
37
45
  } from "./index-fbewhg4g.js";
38
- import {
39
- getNpmRegistryUrl,
40
- getLatestPackageVersion
41
- } from "./index-m5n3ka0p.js";
42
46
 
43
47
  // pkgs/@akanjs/cli/workspace/workspace.runner.ts
44
48
  import { mkdir, writeFile as writeFile2 } from "fs/promises";
49
+ import os from "os";
45
50
  import path5 from "path";
46
51
 
47
52
  // pkgs/@akanjs/devkit/biomeBase.ts
@@ -744,7 +749,7 @@ class MaintainabilityReport {
744
749
  "akan.component.write-chain": "Move the writes into one service method behind one endpoint, called by one store action the handler calls once; a component chaining `st.do` writes, or writing once per item, leaves an agent or another screen half-done.",
745
750
  "akan.component.store-access": MaintainabilityReport.#clientSplitFix,
746
751
  "akan.write.placement": "A server write leaves the browser through one store action, started by one module component. Move a `fetch.<mutation>` into a store action, and hand `ui/` and `webkit/` code the write as an `onX` prop or hook argument from the module's `Zone` or `Util`: they stay free of any one model, and an agent or another screen reaches the write through the store.",
747
- "akan.service.call-in-loop": "Load the set once (`load<Model>Many(ids)`, one filter query) or write it once (one batch method), then loop in memory: a call per item is a round trip per item, so the endpoint slows as its input grows.",
752
+ "akan.service.call-in-loop": "Load the set once (`load<Model>Many(ids)`, one filter query) or write it once (`create<Model>Many(rows)`, one batch method), then loop in memory: a call per item is a round trip per item, so the endpoint slows as its input grows.",
748
753
  "akan.baseline.growth": "Restore the entry from the default branch, then split the file or move the writes instead: `akan lint` lowers an entry as the code shrinks and never raises one."
749
754
  };
750
755
  static #labels = {
@@ -939,11 +944,18 @@ class ServiceLoopCallScanner {
939
944
  }
940
945
 
941
946
  // pkgs/@akanjs/devkit/signalMutationIndex.ts
947
+ import { modelNames } from "akanjs/common";
942
948
  import ts8 from "typescript";
943
949
 
944
950
  class SignalMutationIndex {
945
- static #generatedArgCounts = { create: 1, update: 2, remove: 1, merge: 2 };
946
- static #argMethods = new Set(["param", "body", "search", "room", "msg"]);
951
+ static #generatedArgCounts = [
952
+ ["createModel", 1],
953
+ ["updateModel", 2],
954
+ ["removeModel", 1],
955
+ ["mergeModel", 2],
956
+ ["addModelFiles", 2]
957
+ ];
958
+ static #reader = createFactReader(ts8, createAst(ts8));
947
959
  #shapesByOwner = new Map;
948
960
  constructor(sourceFiles) {
949
961
  for (const { file, sourceFile } of sourceFiles) {
@@ -951,7 +963,7 @@ class SignalMutationIndex {
951
963
  continue;
952
964
  const owner = file.split("/").slice(0, 2).join("/");
953
965
  const shapes = this.#shapesByOwner.get(owner) ?? new Map;
954
- SignalMutationIndex.#collect(sourceFile, shapes);
966
+ SignalMutationIndex.#collect(SignalMutationIndex.#reader.read(sourceFile, owner), shapes);
955
967
  this.#shapesByOwner.set(owner, shapes);
956
968
  }
957
969
  }
@@ -974,91 +986,25 @@ class SignalMutationIndex {
974
986
  }
975
987
  return;
976
988
  }
977
- static #collect(sourceFile, kinds) {
978
- const visit = (node) => {
979
- if (ts8.isCallExpression(node) && ts8.isIdentifier(node.expression)) {
980
- if (node.expression.text === "slice")
981
- SignalMutationIndex.#collectGenerated(node, kinds);
982
- else if (node.expression.text === "endpoint")
983
- SignalMutationIndex.#collectEndpoints(node, kinds);
984
- }
985
- ts8.forEachChild(node, visit);
986
- };
987
- visit(sourceFile);
988
- }
989
- static #collectGenerated(slice, kinds) {
990
- let service = slice.arguments[0];
991
- while (service && ts8.isCallExpression(service) && ts8.isPropertyAccessExpression(service.expression))
992
- service = service.expression.expression;
993
- if (!service || !ts8.isPropertyAccessExpression(service) || !SignalMutationIndex.#isNamed(service.expression, "srv"))
994
- return;
995
- const model = service.name.text;
996
- const capModel = `${model.charAt(0).toUpperCase()}${model.slice(1)}`;
997
- for (const [verb, argCount] of Object.entries(SignalMutationIndex.#generatedArgCounts))
998
- kinds.set(`${verb}${capModel}`, { kind: "mutation", argCount });
999
- kinds.set(`add${capModel}Files`, { kind: "mutation", argCount: 2 });
1000
- }
1001
- static #collectEndpoints(endpoint, kinds) {
1002
- const builder = endpoint.arguments[1];
1003
- if (!builder || !ts8.isArrowFunction(builder) && !ts8.isFunctionExpression(builder))
1004
- return;
1005
- const map = SignalMutationIndex.#returnedObjectOf(builder);
1006
- if (!map)
1007
- return;
1008
- const verbOf = SignalMutationIndex.#verbReaderOf(builder.parameters[0]);
1009
- for (const property of map.properties) {
1010
- if (!ts8.isPropertyAssignment(property))
989
+ static #collect(facts, shapes) {
990
+ for (const { model } of facts.slices) {
991
+ if (!model)
1011
992
  continue;
1012
- if (!ts8.isIdentifier(property.name) && !ts8.isStringLiteral(property.name))
1013
- continue;
1014
- const { root, argCount } = SignalMutationIndex.#chainOf(property.initializer);
1015
- const verb = verbOf(root);
1016
- const kind = verb === "message" ? "mutation" : verb;
1017
- if (kind === "query" || kind === "mutation")
1018
- kinds.set(property.name.text, { kind, argCount });
993
+ const names = modelNames(model);
994
+ for (const [role, argCount] of SignalMutationIndex.#generatedArgCounts)
995
+ shapes.set(names[role], { kind: "mutation", argCount });
1019
996
  }
1020
- }
1021
- static #returnedObjectOf(builder) {
1022
- let body = builder.body;
1023
- if (ts8.isBlock(body))
1024
- body = body.statements.find(ts8.isReturnStatement)?.expression;
1025
- while (body && ts8.isParenthesizedExpression(body))
1026
- body = body.expression;
1027
- return body && ts8.isObjectLiteralExpression(body) ? body : null;
1028
- }
1029
- static #verbReaderOf(parameter) {
1030
- const verbs = new Map;
1031
- if (parameter && ts8.isObjectBindingPattern(parameter.name))
1032
- for (const element of parameter.name.elements) {
1033
- const verb = element.propertyName ?? element.name;
1034
- if (ts8.isIdentifier(verb) && ts8.isIdentifier(element.name))
1035
- verbs.set(element.name.text, verb.text);
997
+ for (const { keys } of facts.endpoints)
998
+ for (const { name, verb, argCount } of keys) {
999
+ const kind = verb === "message" ? "mutation" : verb;
1000
+ if (kind === "query" || kind === "mutation")
1001
+ shapes.set(name, { kind, argCount });
1036
1002
  }
1037
- const holder = parameter && ts8.isIdentifier(parameter.name) ? parameter.name.text : null;
1038
- return (callee) => {
1039
- if (callee && ts8.isIdentifier(callee))
1040
- return verbs.get(callee.text);
1041
- if (callee && ts8.isPropertyAccessExpression(callee) && SignalMutationIndex.#isNamed(callee.expression, holder))
1042
- return callee.name.text;
1043
- return;
1044
- };
1045
- }
1046
- static #isNamed(expression, name) {
1047
- return ts8.isIdentifier(expression) && expression.text === name;
1048
- }
1049
- static #chainOf(initializer) {
1050
- let root = initializer;
1051
- let argCount = 0;
1052
- while (ts8.isCallExpression(root) && ts8.isPropertyAccessExpression(root.expression) && ts8.isCallExpression(root.expression.expression)) {
1053
- if (SignalMutationIndex.#argMethods.has(root.expression.name.text))
1054
- argCount += 1;
1055
- root = root.expression.expression;
1056
- }
1057
- return { root: ts8.isCallExpression(root) ? root.expression : undefined, argCount };
1058
1003
  }
1059
1004
  }
1060
1005
 
1061
1006
  // pkgs/@akanjs/devkit/storeSource.ts
1007
+ import { modelNames as modelNames2 } from "akanjs/common";
1062
1008
  import ts9 from "typescript";
1063
1009
 
1064
1010
  class StoreSource {
@@ -1069,15 +1015,15 @@ class StoreSource {
1069
1015
  #ownActionsByStore = new Map;
1070
1016
  #rootAliasesByMethod = new Map;
1071
1017
  static generatedWritesOf(refName) {
1072
- const model = `${refName.charAt(0).toUpperCase()}${refName.slice(1)}`;
1018
+ const names = modelNames2(refName);
1073
1019
  return [
1074
- `create${model}`,
1075
- `update${model}`,
1076
- `remove${model}`,
1077
- `merge${model}`,
1078
- `create${model}InForm`,
1079
- `update${model}InForm`,
1080
- `submit${model}`
1020
+ names.createModel,
1021
+ names.updateModel,
1022
+ names.removeModel,
1023
+ names.mergeModel,
1024
+ names.createModelInForm,
1025
+ names.updateModelInForm,
1026
+ names.submitModel
1081
1027
  ];
1082
1028
  }
1083
1029
  constructor({ file, sourceFile }) {
@@ -1596,17 +1542,11 @@ class MaintainabilityPaths {
1596
1542
 
1597
1543
  // pkgs/@akanjs/cli/workspace/workspace.runner.ts
1598
1544
  var defaultWorkspacePeerDependencies = new Set([
1599
- "@react-spring/web",
1600
- "@use-gesture/react",
1601
1545
  "chance",
1602
1546
  "react",
1603
1547
  "react-dom",
1604
1548
  "react-icons",
1605
- "react-refresh",
1606
1549
  "react-server-dom-webpack",
1607
- "react-spring",
1608
- "scheduler",
1609
- "tailwind-scrollbar",
1610
1550
  "tailwindcss",
1611
1551
  "typescript"
1612
1552
  ]);
@@ -1614,6 +1554,7 @@ var defaultWorkspaceTypeDependencies = { "@types/react": "^19.3.0", "@types/reac
1614
1554
  var defaultMaxDiagnostics = 200;
1615
1555
 
1616
1556
  class WorkspaceRunner extends runner("workspace") {
1557
+ static fallbackGitIdentity = { name: "Akan.js", email: "noreply@akanjs.com" };
1617
1558
  async machineKeygen(workspace, out) {
1618
1559
  const file = path5.resolve(workspace.workspaceRoot, out);
1619
1560
  const { privatePem, publicKey } = Ed25519Key.generate();
@@ -1642,22 +1583,39 @@ class WorkspaceRunner extends runner("workspace") {
1642
1583
  }
1643
1584
  async createWorkspace(repoName, appName, {
1644
1585
  dirname = ".",
1586
+ inPlace = false,
1645
1587
  init = true,
1646
1588
  akanVersion,
1647
1589
  registryUrl,
1648
- owner = ""
1590
+ owner = "",
1591
+ libs = []
1649
1592
  }) {
1650
1593
  const cwdPath = process.cwd();
1651
- const workspaceRoot = path5.resolve(cwdPath, dirname, repoName);
1594
+ const workspaceRoot = inPlace ? path5.resolve(cwdPath, dirname) : path5.resolve(cwdPath, dirname, repoName);
1595
+ this.#refuseSharedFolder(workspaceRoot);
1652
1596
  const normalizedRegistryUrl = registryUrl ? getNpmRegistryUrl(registryUrl) : undefined;
1653
- const workspace = WorkspaceExecutor.fromRoot({ workspaceRoot, repoName });
1654
- const templateSpinner = workspace.spinning(`Creating workspace template files in ${workspaceRoot}...`);
1655
- const latestTypesBunVersion = await getLatestPackageVersion("@types/bun", "latest", normalizedRegistryUrl);
1656
- await workspace.applyTemplate({
1597
+ const rootTemplate = {
1657
1598
  basePath: ".",
1658
1599
  template: "workspaceRoot",
1659
1600
  dict: { repoName, appName, serveDomain: "localhost", owner }
1601
+ };
1602
+ const workspace = WorkspaceExecutor.fromRoot({ workspaceRoot, repoName });
1603
+ const fsRoot = path5.parse(workspaceRoot).root;
1604
+ const planned = await WorkspaceExecutor.fromRoot({ workspaceRoot: fsRoot, repoName }).applyTemplate({
1605
+ ...rootTemplate,
1606
+ dryRun: true
1660
1607
  });
1608
+ const writes = [
1609
+ ...planned.map((file) => path5.relative(fsRoot, file.filePath)),
1610
+ ...normalizedRegistryUrl ? [".npmrc"] : [],
1611
+ `apps/${appName}`,
1612
+ ...libs.map((libName) => `libs/${libName}`)
1613
+ ];
1614
+ this.#refuseMisresolvedPaths(workspace, writes);
1615
+ await this.#refuseToOverwrite(workspace, writes);
1616
+ const templateSpinner = workspace.spinning(`Creating workspace template files in ${workspaceRoot}...`);
1617
+ const latestTypesBunVersion = await getLatestPackageVersion("@types/bun", "latest", normalizedRegistryUrl);
1618
+ await workspace.applyTemplate(rootTemplate);
1661
1619
  if (normalizedRegistryUrl)
1662
1620
  await workspace.writeFile(".npmrc", `registry=${normalizedRegistryUrl}/
1663
1621
  `);
@@ -1692,6 +1650,48 @@ class WorkspaceRunner extends runner("workspace") {
1692
1650
  }
1693
1651
  return workspace;
1694
1652
  }
1653
+ #refuseSharedFolder(root) {
1654
+ const shared = root === path5.resolve(os.homedir()) ? "your home folder" : path5.dirname(root) === root ? "a filesystem root" : null;
1655
+ if (!shared)
1656
+ return;
1657
+ throw new Error(`${root} is ${shared}, and a workspace there would commit every file below it and write its agent and MCP ` + "settings over your global ones. Create the workspace in a folder of its own.");
1658
+ }
1659
+ #refuseMisresolvedPaths(workspace, paths) {
1660
+ const root = workspace.workspaceRoot;
1661
+ const misresolved = paths.filter((target) => workspace.getPath(target) !== path5.join(root, target)).sort((a, b) => a.localeCompare(b));
1662
+ if (!misresolved.length)
1663
+ return;
1664
+ throw new Error(`Akan would write ${misresolved.join(", ")} to the wrong place in ${root}, since it drops a path's leading ` + "folders when the workspace folder's path ends with them. Create the workspace in a folder with another name.");
1665
+ }
1666
+ async#refuseToOverwrite(workspace, paths) {
1667
+ const occupied = [];
1668
+ for (const target of paths)
1669
+ if (await workspace.exists(target))
1670
+ occupied.push(target);
1671
+ if (!occupied.length)
1672
+ return;
1673
+ occupied.sort((a, b) => a.localeCompare(b));
1674
+ throw new Error(`${workspace.workspaceRoot} already holds ${occupied.join(", ")}, which a new workspace would overwrite. ` + "Move them out of the way, or create the workspace in an empty folder.");
1675
+ }
1676
+ async commitWorkspace(workspace) {
1677
+ const root = workspace.workspaceRoot;
1678
+ const outer = (await WorkspaceRunner.#git(root, ["rev-parse", "--show-toplevel"]))?.trim();
1679
+ if (outer && await WorkspaceRunner.#git(root, ["check-ignore", "-q", path5.join(root, "package.json")]) === null)
1680
+ return { committed: false, repository: outer };
1681
+ const known = await Promise.all(["GIT_AUTHOR_IDENT", "GIT_COMMITTER_IDENT"].map((ident) => WorkspaceRunner.#git(root, ["var", ident])));
1682
+ const identity = known.every((ident) => ident !== null) ? undefined : WorkspaceRunner.fallbackGitIdentity;
1683
+ await workspace.commit("Initial commit", { init: true, ...identity ? { identity } : {} });
1684
+ return { committed: true, repository: root, identity: identity ?? null };
1685
+ }
1686
+ static async#git(cwd, args) {
1687
+ try {
1688
+ const proc = Bun.spawn(["git", ...args], { cwd, env: process.env, stdout: "pipe", stderr: "ignore" });
1689
+ const [stdout, code] = await Promise.all([new Response(proc.stdout).text(), proc.exited]);
1690
+ return code === 0 ? stdout : null;
1691
+ } catch {
1692
+ return null;
1693
+ }
1694
+ }
1695
1695
  async#getAkanPeerDependencies() {
1696
1696
  const [packageJson, cliPackageJson] = await Promise.all([this.#getAkanPackageJson(), this.#getCliPackageJson()]);
1697
1697
  const dependencyVersions = {
@@ -2041,18 +2041,58 @@ class DeprecatedCommentScanner {
2041
2041
  }
2042
2042
 
2043
2043
  // pkgs/@akanjs/devkit/formSetterScanner.ts
2044
+ import { capitalize, formSetterNames } from "akanjs/common";
2044
2045
  import ts14 from "typescript";
2045
2046
 
2046
2047
  class FormSetterScanner {
2047
- static #fieldSetter = /^set[A-Za-z0-9_$]*On[A-Za-z0-9_$]*$/;
2048
+ static #constantPath = /(?:^|\/)lib\/([^_/][^/]*)\/\1\.constant\.ts$/;
2049
+ static #baseFields = ["id", "createdAt", "updatedAt", "removedAt"];
2048
2050
  scan(sourceFiles) {
2049
- return sourceFiles.filter((sourceFile) => sourceFile.file.endsWith(".tsx")).flatMap((f) => this.#scanFile(f));
2051
+ const fieldSetters = FormSetterScanner.#fieldSettersOf(sourceFiles);
2052
+ return sourceFiles.filter((sourceFile) => sourceFile.file.endsWith(".tsx")).flatMap((f) => this.#scanFile(f, fieldSetters));
2053
+ }
2054
+ static #fieldSettersOf(sourceFiles) {
2055
+ const setters = new Set;
2056
+ for (const { file, sourceFile } of sourceFiles) {
2057
+ const refName = FormSetterScanner.#constantPath.exec(file)?.[1];
2058
+ if (!refName)
2059
+ continue;
2060
+ const className = capitalize(refName);
2061
+ const fullModelClasses = new Set([`${className}Input`, `${className}Object`, `Light${className}`, className]);
2062
+ const keys = new Set(FormSetterScanner.#baseFields);
2063
+ for (const statement of sourceFile.statements)
2064
+ if (ts14.isClassDeclaration(statement) && statement.name && fullModelClasses.has(statement.name.text))
2065
+ for (const key of FormSetterScanner.#viaFieldKeysOf(statement))
2066
+ keys.add(key);
2067
+ for (const key of keys)
2068
+ setters.add(formSetterNames(className, key).setFieldOnModel);
2069
+ }
2070
+ return setters;
2071
+ }
2072
+ static #viaFieldKeysOf(declaration) {
2073
+ const via = declaration.heritageClauses?.find((clause) => clause.token === ts14.SyntaxKind.ExtendsKeyword)?.types[0]?.expression;
2074
+ if (!via || !ts14.isCallExpression(via))
2075
+ return [];
2076
+ return via.arguments.flatMap((argument) => {
2077
+ if (!ts14.isArrowFunction(argument) && !ts14.isFunctionExpression(argument))
2078
+ return [];
2079
+ const fields = FormSetterScanner.#returnedObjectOf(argument.body);
2080
+ return (fields?.properties ?? []).flatMap((property) => property.name && (ts14.isIdentifier(property.name) || ts14.isStringLiteral(property.name)) ? [property.name.text] : []);
2081
+ });
2082
+ }
2083
+ static #returnedObjectOf(body) {
2084
+ let expression = body;
2085
+ if (ts14.isBlock(body))
2086
+ expression = body.statements.find(ts14.isReturnStatement)?.expression;
2087
+ while (expression && (ts14.isParenthesizedExpression(expression) || ts14.isAsExpression(expression)))
2088
+ expression = expression.expression;
2089
+ return expression && ts14.isObjectLiteralExpression(expression) ? expression : null;
2050
2090
  }
2051
- #scanFile({ file, sourceFile }) {
2091
+ #scanFile({ file, sourceFile }, fieldSetters) {
2052
2092
  const wrapped = [];
2053
2093
  const visit = (node) => {
2054
2094
  if (ts14.isJsxAttribute(node)) {
2055
- const setter = FormSetterScanner.#wrappedSetterOf(node);
2095
+ const setter = FormSetterScanner.#wrappedSetterOf(node, fieldSetters);
2056
2096
  if (setter)
2057
2097
  wrapped.push({ setter, line: FormSetterScanner.#lineOf(sourceFile, node) });
2058
2098
  }
@@ -2074,7 +2114,7 @@ class FormSetterScanner {
2074
2114
  }
2075
2115
  ];
2076
2116
  }
2077
- static #wrappedSetterOf(attribute) {
2117
+ static #wrappedSetterOf(attribute, fieldSetters) {
2078
2118
  if (!ts14.isIdentifier(attribute.name) || !/^on[A-Z]/.test(attribute.name.text))
2079
2119
  return null;
2080
2120
  const initializer = attribute.initializer;
@@ -2085,16 +2125,16 @@ class FormSetterScanner {
2085
2125
  return null;
2086
2126
  if (!handler.parameters.length)
2087
2127
  return null;
2088
- return FormSetterScanner.#setterCallIn(handler.body);
2128
+ return FormSetterScanner.#setterCallIn(handler.body, fieldSetters);
2089
2129
  }
2090
- static #setterCallIn(node) {
2130
+ static #setterCallIn(node, fieldSetters) {
2091
2131
  let found = null;
2092
2132
  const visit = (current) => {
2093
2133
  if (found)
2094
2134
  return;
2095
2135
  if (ts14.isCallExpression(current) && ts14.isPropertyAccessExpression(current.expression)) {
2096
2136
  const { expression, name } = current.expression;
2097
- if (ts14.isPropertyAccessExpression(expression) && ts14.isIdentifier(expression.expression) && expression.expression.text === "st" && expression.name.text === "do" && FormSetterScanner.#fieldSetter.test(name.text)) {
2137
+ if (ts14.isPropertyAccessExpression(expression) && ts14.isIdentifier(expression.expression) && expression.expression.text === "st" && expression.name.text === "do" && fieldSetters.has(name.text)) {
2098
2138
  found = name.text;
2099
2139
  return;
2100
2140
  }
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  AppInfo
4
- } from "./index-8scw1pjk.js";
4
+ } from "./index-g500c5j9.js";
5
5
 
6
6
  // pkgs/@akanjs/devkit/slicePlanner.ts
7
7
  class SlicePlanner {
@@ -7,22 +7,22 @@ import {
7
7
  ExitCodeError,
8
8
  markCliErrorPrinted,
9
9
  assertPromptable
10
- } from "./index-eja64h28.js";
10
+ } from "./index-9zy8479y.js";
11
11
  import {
12
12
  AppExecutor,
13
13
  LibExecutor,
14
14
  PkgExecutor
15
- } from "./index-8scw1pjk.js";
15
+ } from "./index-g500c5j9.js";
16
16
  import {
17
17
  DesktopServerStage
18
- } from "./index-w7q6h97v.js";
18
+ } from "./index-0j1t1h2b.js";
19
19
  import {
20
20
  LibraryScript
21
- } from "./index-xq543a5y.js";
21
+ } from "./index-y4kcmbt2.js";
22
22
  import {
23
23
  ApplicationRunner,
24
24
  VerifyScope
25
- } from "./index-s6da8ta9.js";
25
+ } from "./index-2mwjshz5.js";
26
26
  import {
27
27
  PreviewChrome2,
28
28
  PreviewView2,
@@ -30,7 +30,7 @@ import {
30
30
  } from "./index-tenw3mah.js";
31
31
  import {
32
32
  formatSlicePlan
33
- } from "./index-1p0qbq3m.js";
33
+ } from "./index-defp4gmb.js";
34
34
  import {
35
35
  openBrowser
36
36
  } from "./index-9dp031by.js";
@@ -685,10 +685,11 @@ class AppPreview {
685
685
  }
686
686
  }
687
687
  static pagePaths(paths, i18n, { csr }) {
688
+ const keepsUnprefixed = i18n.localePrefix === "as-needed" && !csr;
688
689
  const pages = (paths.length ? paths : ["/"]).map((raw) => {
689
690
  const url = new URL(/^https?:\/\//.test(raw) ? raw : `http://localhost${raw.startsWith("/") ? "" : "/"}${raw}`);
690
691
  const [first] = url.pathname.split("/").filter(Boolean);
691
- if (!first || !i18n.locales.includes(first))
692
+ if (!keepsUnprefixed && (!first || !i18n.locales.includes(first)))
692
693
  url.pathname = `/${i18n.defaultLocale}${url.pathname === "/" ? "/" : url.pathname}`;
693
694
  if (csr) {
694
695
  url.searchParams.set("csr", "true");
@@ -1576,11 +1577,12 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
1576
1577
  await Promise.all(shares.map(async (share) => await share.close()));
1577
1578
  }, "Abandoning the tunnel release; the shares expire on their own.");
1578
1579
  await Promise.all(apps.map(async (app) => {
1579
- const { TunnelShare } = await import("./TunnelShare-xyjpa7gx.js");
1580
+ const { TunnelShare } = await import("./TunnelShare-hdq9h1hr.js");
1580
1581
  const share = await TunnelShare.open(app, { workspace: app.workspace });
1581
1582
  shares.push(share);
1582
1583
  urls.set(app.name, share.url);
1583
1584
  Logger3.rawLog(`${app.name} is shared at ${share.url}`);
1585
+ Logger3.rawLog(TunnelShare.exposureNotice(app.name, false));
1584
1586
  })).catch((error) => {
1585
1587
  Logger3.rawLog(`Could not open the tunnel: ${toError(error).message}`, undefined, "error");
1586
1588
  });
@@ -4,7 +4,7 @@ import {
4
4
  script,
5
5
  ExitCodeError,
6
6
  markCliErrorPrinted
7
- } from "./index-eja64h28.js";
7
+ } from "./index-9zy8479y.js";
8
8
  import {
9
9
  AGENT_BLOCK_START,
10
10
  AGENT_BLOCK_END,
@@ -15,33 +15,33 @@ import {
15
15
  CLAUDE_COMMENT_RULE,
16
16
  AppExecutor,
17
17
  LibExecutor
18
- } from "./index-8scw1pjk.js";
18
+ } from "./index-g500c5j9.js";
19
+ import {
20
+ akanCodePaths2
21
+ } from "./index-35j83zkd.js";
19
22
  import {
20
23
  ConventionSet,
21
24
  Prompter2
22
- } from "./index-r2wedvqn.js";
25
+ } from "./index-j6eeh5d7.js";
23
26
  import {
24
27
  collectRecipeSources2,
25
28
  scanRecipes2
26
29
  } from "./index-hj6w4ka1.js";
27
30
  import {
28
31
  AkanContextAnalyzer
29
- } from "./index-tgt2fnd6.js";
32
+ } from "./index-j7hwy56s.js";
30
33
  import {
31
34
  ApplicationRunner,
32
35
  VerifyScope
33
- } from "./index-s6da8ta9.js";
36
+ } from "./index-2mwjshz5.js";
34
37
  import {
35
38
  WorkspaceRunner
36
- } from "./index-am36s3jh.js";
39
+ } from "./index-cjmjvg4r.js";
37
40
  import {
38
41
  VerifyComments,
39
42
  VerifyPipeline,
40
43
  VerifyReport
41
- } from "./index-b8c289dx.js";
42
- import {
43
- akanCodePaths2
44
- } from "./index-jje9qzyq.js";
44
+ } from "./index-7apsdr5g.js";
45
45
 
46
46
  // pkgs/@akanjs/cli/agent/agent.script.ts
47
47
  import { Logger as Logger3 } from "akanjs/common";