@akanjs/cli 3.1.0-rc.20 → 3.1.0-rc.22

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 (76) hide show
  1. package/.build-stamp +1 -1
  2. package/{CodeAgent-n3tzjm91.js → CodeAgent-fee0pnwp.js} +2 -2
  3. package/{CodeTui-fnm9ft4d.js → CodeTui-xh71b2k8.js} +1 -1
  4. package/TunnelShare-s7bpe55e.js +14 -0
  5. package/{agent.command-3qxf4xcj.js → agent.command-tge9rvmt.js} +5 -5
  6. package/akanCode.js +2 -2
  7. package/{application.command-zfja7x4r.js → application.command-j5b8yrcf.js} +35 -9
  8. package/{applicationBuildRunner-vh4j6vdv.js → applicationBuildRunner-s41mgz21.js} +21 -7
  9. package/buildBatch.proc.js +9 -9
  10. package/{cloud.command-fcc8e8tp.js → cloud.command-q9srng6e.js} +13 -13
  11. package/cloud.script-vfsd4gxs.js +24 -0
  12. package/{code.command-130bdmhe.js → code.command-n6r6zt97.js} +6 -6
  13. package/commandManifest.json +1 -1
  14. package/{context.command-0qx447mb.js → context.command-1je84w1b.js} +16 -16
  15. package/context.runner-xg0ngz93.js +25 -0
  16. package/{guideline.command-cv5bmrx2.js → guideline.command-0e0sx2vg.js} +2 -2
  17. package/guidelines/conventions/conventions.instruction.md +42 -13
  18. package/guidelines/mcpRule/mcpRule.instruction.md +88 -47
  19. package/guidelines/pageRule/pageRule.instruction.md +53 -8
  20. package/guidelines/runtimeRule/runtimeRule.instruction.md +8 -1
  21. package/guidelines/ssrRule/ssrRule.instruction.md +8 -5
  22. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +1 -1
  23. package/incrementalBuilder.proc.js +3 -3
  24. package/{index-fmzcs8v6.js → index-1bhv9dh4.js} +4 -4
  25. package/{index-qtfmtcrw.js → index-1xqq3va9.js} +71 -18
  26. package/{index-86jt2a0e.js → index-3xhak9e0.js} +1 -1
  27. package/{index-tamvyvj3.js → index-4fe4qqgn.js} +3 -3
  28. package/{index-g1mbppa9.js → index-551gh8h2.js} +5 -5
  29. package/{index-trpasv9q.js → index-5m0s0gdv.js} +1 -1
  30. package/index-6mprvdt8.js +566 -0
  31. package/{index-192ha4xh.js → index-6nqnqzv1.js} +1 -1
  32. package/{index-dye8pnxx.js → index-73esn3y2.js} +1 -1
  33. package/{index-4mhy6qme.js → index-7xy30jev.js} +4 -4
  34. package/{index-1xj2t7cb.js → index-85h3dhe0.js} +7 -7
  35. package/{index-axs61rna.js → index-8abyrfw8.js} +5 -4
  36. package/{index-1p98exm2.js → index-94jq9cbz.js} +2 -2
  37. package/{index-cpb3nvma.js → index-9h0z0tjr.js} +2 -2
  38. package/{index-hsadfb6c.js → index-c9rfak6r.js} +7 -7
  39. package/{index-w44cy4vs.js → index-cgyqx6q1.js} +2 -2
  40. package/{index-d72hfmdm.js → index-cq5x7a9k.js} +8 -8
  41. package/{index-j237xtew.js → index-deckcwbg.js} +2 -2
  42. package/{index-vk0pa0mn.js → index-ex35dg39.js} +2 -1
  43. package/{index-35hc95h5.js → index-f9118j70.js} +1 -1
  44. package/{index-jw1zm273.js → index-g5px5pxd.js} +53 -9
  45. package/{index-va06nr10.js → index-gxqvev8w.js} +52 -12
  46. package/{index-fyq1z6kt.js → index-hagw9c94.js} +3 -3
  47. package/{index-pydbnfez.js → index-p44jnjfr.js} +2 -2
  48. package/{index-awbdfcf2.js → index-rp9anyeb.js} +4 -4
  49. package/{index-j4mkhz93.js → index-t8npm331.js} +3 -3
  50. package/{index-5edzv8fn.js → index-tbmtmkhx.js} +2 -2
  51. package/{index-1djcjcre.js → index-vyh8kemm.js} +3 -3
  52. package/{index-qwa5k1j8.js → index-x7bny3wv.js} +1 -1
  53. package/index.js +22 -22
  54. package/{library.command-erp2f56n.js → library.command-ys9s0mtc.js} +3 -3
  55. package/{localRegistry.command-hj3p16p5.js → localRegistry.command-kmp3sd47.js} +12 -12
  56. package/{module.command-gs2r615e.js → module.command-5sx9453y.js} +5 -5
  57. package/{package.command-j10r76ax.js → package.command-s0d3417k.js} +3 -3
  58. package/package.json +2 -2
  59. package/{page.command-4h4a8pnh.js → page.command-zsa03pmc.js} +3 -3
  60. package/{pipeline.command-a2nrk26m.js → pipeline.command-j8h6qsha.js} +2 -2
  61. package/{primitive.command-w6t0asqz.js → primitive.command-n2978nmw.js} +6 -6
  62. package/{projectTypecheck-f534enqj.js → projectTypecheck-qg2jf80j.js} +1 -1
  63. package/{quality.command-77x7vbbx.js → quality.command-7kgz46st.js} +2 -2
  64. package/{repair.command-y6sstev7.js → repair.command-2sszcckw.js} +5 -5
  65. package/{routeSourceValidator-7ycnfz0e.js → routeSourceValidator-6jd0q6r6.js} +47 -14
  66. package/{scalar.command-20b8cy0k.js → scalar.command-230jrhzf.js} +4 -4
  67. package/{subspace.command-baz73jpk.js → subspace.command-y5v4ypd3.js} +8 -8
  68. package/templates/migration/__migrationId__.ts +23 -0
  69. package/templates/server.ts +8 -1
  70. package/{tunnel.command-2kw8vt9g.js → tunnel.command-ja29zghd.js} +7 -7
  71. package/{workflow.command-2djwmpqf.js → workflow.command-0eg8czt5.js} +10 -10
  72. package/{workspace.command-jqs7vjhe.js → workspace.command-zcym1dk5.js} +24 -24
  73. package/TunnelShare-661cxz5e.js +0 -14
  74. package/cloud.script-1xt3tnts.js +0 -24
  75. package/context.runner-1vsjztjg.js +0 -25
  76. package/index-665zp9rs.js +0 -271
package/.build-stamp CHANGED
@@ -1 +1 @@
1
- 6ee016177b53c853f3bec400bfc5dd004b72cdb2f4e216c9b3d40c0ac292dcfe
1
+ ff52b306f8c96b86a1bb9a1ea7d4a3a02deeb65d3184e77f02398b6eab82b052
@@ -1,8 +1,8 @@
1
1
  // @bun
2
2
  import {
3
3
  CodeAgent2
4
- } from "./index-1djcjcre.js";
5
- import"./index-dye8pnxx.js";
4
+ } from "./index-vyh8kemm.js";
5
+ import"./index-73esn3y2.js";
6
6
  import"./index-7md2g9vw.js";
7
7
  export {
8
8
  CodeAgent2 as CodeAgent
@@ -5,7 +5,7 @@ import {
5
5
  McpTokenStore,
6
6
  McpSignIn,
7
7
  AkanCodeCompaction2
8
- } from "./index-dye8pnxx.js";
8
+ } from "./index-73esn3y2.js";
9
9
  import {
10
10
  CodeTuiLines2,
11
11
  CodeTuiAgents2,
@@ -0,0 +1,14 @@
1
+ // @bun
2
+ import {
3
+ TunnelShare2
4
+ } from "./index-x7bny3wv.js";
5
+ import"./index-9h0z0tjr.js";
6
+ import"./index-551gh8h2.js";
7
+ import"./index-m9jj544v.js";
8
+ import"./index-6mprvdt8.js";
9
+ import"./index-6nqnqzv1.js";
10
+ import"./index-gxqvev8w.js";
11
+ import"./index-52w0fvh8.js";
12
+ export {
13
+ TunnelShare2 as TunnelShare
14
+ };
@@ -2,16 +2,16 @@
2
2
  import {
3
3
  Workspace,
4
4
  command
5
- } from "./index-jw1zm273.js";
5
+ } from "./index-g5px5pxd.js";
6
6
  import"./index-52w0fvh8.js";
7
- import"./index-va06nr10.js";
7
+ import"./index-gxqvev8w.js";
8
8
  import"./index-hj6w4ka1.js";
9
- import"./index-trpasv9q.js";
10
- import"./index-5edzv8fn.js";
9
+ import"./index-5m0s0gdv.js";
10
+ import"./index-tbmtmkhx.js";
11
11
  import"./index-zzvvc845.js";
12
12
  import {
13
13
  AgentScript
14
- } from "./index-tamvyvj3.js";
14
+ } from "./index-4fe4qqgn.js";
15
15
 
16
16
  // pkgs/@akanjs/cli/agent/agent.command.ts
17
17
  class AgentCommand extends command("agent", [AgentScript], ({ public: target }) => ({
package/akanCode.js CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  CodeMailbox2,
29
29
  CodeSessionFork2,
30
30
  CodeAgent2
31
- } from "./index-1djcjcre.js";
31
+ } from "./index-vyh8kemm.js";
32
32
  import {
33
33
  akanCodeDefaultModel2,
34
34
  akanCodeModel2,
@@ -40,7 +40,7 @@ import {
40
40
  SubagentPool2,
41
41
  akanCodePaths2,
42
42
  AkanCodeCompaction2
43
- } from "./index-dye8pnxx.js";
43
+ } from "./index-73esn3y2.js";
44
44
  import"./index-7md2g9vw.js";
45
45
  import {
46
46
  CodeAgentRpcHost2
@@ -7,18 +7,19 @@ import {
7
7
  Exec,
8
8
  Workspace,
9
9
  command
10
- } from "./index-jw1zm273.js";
10
+ } from "./index-g5px5pxd.js";
11
11
  import"./index-52w0fvh8.js";
12
- import"./index-va06nr10.js";
12
+ import"./index-gxqvev8w.js";
13
13
  import"./index-5nd1wtkv.js";
14
- import"./index-vk0pa0mn.js";
14
+ import"./index-ex35dg39.js";
15
15
  import"./index-m9jj544v.js";
16
- import"./index-g1mbppa9.js";
17
- import"./index-192ha4xh.js";
18
- import"./index-pydbnfez.js";
16
+ import"./index-551gh8h2.js";
17
+ import"./index-6mprvdt8.js";
18
+ import"./index-6nqnqzv1.js";
19
+ import"./index-p44jnjfr.js";
19
20
  import {
20
21
  ApplicationScript
21
- } from "./index-qtfmtcrw.js";
22
+ } from "./index-1xqq3va9.js";
22
23
  import"./index-7md2g9vw.js";
23
24
  import {
24
25
  writeOption,
@@ -27,10 +28,11 @@ import {
27
28
  allowLocalOption,
28
29
  publicEnvOption
29
30
  } from "./index-mdjc93e1.js";
30
- import"./index-35hc95h5.js";
31
- import"./index-665zp9rs.js";
31
+ import"./index-f9118j70.js";
32
32
 
33
33
  // pkgs/@akanjs/cli/application/application.command.ts
34
+ import { MigrationCommand } from "akanjs/server/migration/migrationCommand";
35
+ import { MigrationError } from "akanjs/server/migration/migrationError";
34
36
  var deviceOption = {
35
37
  desc: "simulator, emulator or device to run on: its id or name (e.g. 'iPhone 17' or 'Pixel_10')",
36
38
  default: ""
@@ -62,6 +64,30 @@ class ApplicationCommand extends command("application", [ApplicationScript], ({
62
64
  script: target({ desc: "Run a custom script in the application" }).with(App).arg("filename", String, { desc: "name of script", nullable: true }).exec(async function(app, filename) {
63
65
  await this.applicationScript.script(app, filename);
64
66
  }),
67
+ migrate: target({
68
+ desc: "List, plan, apply, verify or roll back the app's data migrations in script/migration",
69
+ stdio: true,
70
+ usageExitCode: 2,
71
+ onFailure: async (error, { usage, given }) => {
72
+ if (given.json !== true)
73
+ return;
74
+ const failure = usage ? new MigrationError("usage", MigrationError.messageOf(error)) : error;
75
+ await MigrationCommand.print(MigrationCommand.failure(null, failure), true);
76
+ }
77
+ }).with(App).arg("action", String, { desc: "list, plan, apply, verify or rollback", default: "list" }).arg("target", String, { desc: "migration id; for rollback, an apply's run id too", nullable: true }).option("param", String, { desc: "a param the migration declares, as name=value", multiple: true }).option("expect", String, { desc: "the plan hash an apply must still match", nullable: true }).option("items", Number, { desc: "how many planned decisions to print", nullable: true }).option("actor", String, { desc: "who runs it, as the ledger records", nullable: true }).option("json", Boolean, { desc: "print the result as one JSON line", default: false }).exec(async function(app, action, target, param, expect, items, actor, json) {
78
+ await this.applicationScript.migrate(app, [
79
+ action,
80
+ ...target ? [target] : [],
81
+ ...param.map((each) => `--param=${each}`),
82
+ ...expect ? [`--expect=${expect}`] : [],
83
+ ...items === null ? [] : [`--items=${items}`],
84
+ ...actor ? [`--actor=${actor}`] : [],
85
+ ...json ? ["--json"] : []
86
+ ]);
87
+ }),
88
+ createMigration: target({ desc: "Create a data migration in the app's script/migration" }).arg("migrationName", String, { desc: "what it does, in camelCase", example: "bizLicenseOwnership" }).with(App).exec(async function(migrationName, app) {
89
+ await this.applicationScript.createMigration(app, migrationName);
90
+ }),
65
91
  console: target({ desc: "Open an interactive server console for the application" }).with(App).exec(async function(app) {
66
92
  await this.applicationScript.console(app);
67
93
  }),
@@ -4,20 +4,20 @@ import {
4
4
  Spinner,
5
5
  ProjectTypecheck2,
6
6
  WorkspaceExecutor
7
- } from "./index-va06nr10.js";
7
+ } from "./index-gxqvev8w.js";
8
8
  import"./index-52w0fvh8.js";
9
- import"./index-w44cy4vs.js";
10
- import"./index-192ha4xh.js";
9
+ import"./index-cgyqx6q1.js";
10
+ import"./index-6nqnqzv1.js";
11
11
  import {
12
12
  AllRoutesBuilder,
13
13
  FontPruner,
14
14
  precompressArtifacts,
15
15
  SsrBaseArtifactBuilder
16
- } from "./index-axs61rna.js";
17
- import"./index-62md4dwy.js";
16
+ } from "./index-8abyrfw8.js";
18
17
  import {
19
18
  CsrArtifactBuilder
20
- } from "./index-665zp9rs.js";
19
+ } from "./index-6mprvdt8.js";
20
+ import"./index-62md4dwy.js";
21
21
 
22
22
  // pkgs/@akanjs/devkit/applicationBuildRunner.ts
23
23
  import path2 from "path";
@@ -124,12 +124,26 @@ class ApplicationBuildRunner {
124
124
  get #envDir() {
125
125
  return path2.join(this.#app.cwdPath, "env");
126
126
  }
127
+ #pinImageEnv(baseDevEnv, environment) {
128
+ const imageEnv = {
129
+ AKAN_PUBLIC_ENV: environment,
130
+ AKAN_PUBLIC_REPO_NAME: baseDevEnv.repoName,
131
+ AKAN_PUBLIC_SERVE_DOMAIN: baseDevEnv.serveDomain
132
+ };
133
+ const outranked = Object.entries(imageEnv).filter(([key, value]) => {
134
+ const given = process.env[key];
135
+ return !!given && given !== value && !(key === "AKAN_PUBLIC_ENV" && this.#environment);
136
+ });
137
+ if (outranked.length)
138
+ this.#app.logger.warn(`The workspace .env outranks this process's environment: the bundles and the image take ${outranked.map(([key, value]) => `${key}=${value} (not ${process.env[key]})`).join(", ")}.`);
139
+ Object.assign(process.env, imageEnv);
140
+ }
127
141
  async build({ spinner = false } = {}) {
128
142
  this.#spinner = spinner;
129
143
  const { web, assets, baseDevEnv } = await this.#app.getConfig();
130
144
  const environment = this.#environment ?? baseDevEnv.env;
131
145
  WorkspaceExecutor.assertDeployableEnv(baseDevEnv, environment, "akan build");
132
- process.env.AKAN_PUBLIC_ENV = environment;
146
+ this.#pinImageEnv(baseDevEnv, environment);
133
147
  if (this.#profile)
134
148
  await ServerEnvProfile.assertShippable({ envDir: this.#envDir, environment, profile: this.#profile });
135
149
  await this.#runPhase("prepare", "Preparing output directory", () => this.#app.prepareCommand("build"));
@@ -6,27 +6,27 @@ import {
6
6
  resolveSsrPageEntriesForApp,
7
7
  WorkspaceExecutor,
8
8
  AppExecutor
9
- } from "./index-va06nr10.js";
9
+ } from "./index-gxqvev8w.js";
10
10
  import {
11
11
  computeRouteSeedIndex,
12
12
  saveRouteSeedIndex,
13
13
  CsrDevBundler,
14
14
  SsrDevBundler
15
- } from "./index-w44cy4vs.js";
15
+ } from "./index-cgyqx6q1.js";
16
16
  import"./index-52w0fvh8.js";
17
17
  import {
18
18
  ServerGraphFile,
19
19
  PagesBundleBuilder
20
- } from "./index-192ha4xh.js";
20
+ } from "./index-6nqnqzv1.js";
21
21
  import {
22
22
  CssCompiler,
23
23
  FontOptimizer,
24
24
  SsrBaseArtifactBuilder
25
- } from "./index-axs61rna.js";
26
- import"./index-62md4dwy.js";
25
+ } from "./index-8abyrfw8.js";
27
26
  import {
28
27
  CsrArtifactBuilder
29
- } from "./index-665zp9rs.js";
28
+ } from "./index-6mprvdt8.js";
29
+ import"./index-62md4dwy.js";
30
30
 
31
31
  // pkgs/@akanjs/devkit/incrementalBuilder/buildBatch.proc.ts
32
32
  import path from "path";
@@ -116,10 +116,10 @@ class BuildBatch {
116
116
  async#buildShell() {
117
117
  const started = Date.now();
118
118
  try {
119
- await new CsrArtifactBuilder(this.#app, "start", "en", { cssAssets: this.#request.cssAssets }).build();
120
- this.#logger.verbose(`csr-shell ok (${Date.now() - started}ms)`);
119
+ await new CsrArtifactBuilder(this.#app, "start", "en", { cssAssets: this.#request.cssAssets }).buildMcpAppViews();
120
+ this.#logger.verbose(`mcp-app-views ok (${Date.now() - started}ms)`);
121
121
  } catch (err) {
122
- this.#fail("shell", "csr-shell", err);
122
+ this.#fail("shell", "mcp-app-views", err);
123
123
  }
124
124
  }
125
125
  async#rebuildCsrArtifact(started) {
@@ -3,26 +3,27 @@ import {
3
3
  App,
4
4
  Workspace,
5
5
  command
6
- } from "./index-jw1zm273.js";
6
+ } from "./index-g5px5pxd.js";
7
7
  import"./index-52w0fvh8.js";
8
- import"./index-va06nr10.js";
9
- import"./index-cpb3nvma.js";
8
+ import"./index-gxqvev8w.js";
9
+ import"./index-9h0z0tjr.js";
10
10
  import {
11
11
  PlatformTestRun
12
- } from "./index-fyq1z6kt.js";
13
- import"./index-vk0pa0mn.js";
12
+ } from "./index-hagw9c94.js";
13
+ import"./index-ex35dg39.js";
14
14
  import"./index-m9jj544v.js";
15
- import"./index-g1mbppa9.js";
16
- import"./index-192ha4xh.js";
15
+ import"./index-551gh8h2.js";
16
+ import"./index-6mprvdt8.js";
17
+ import"./index-6nqnqzv1.js";
17
18
  import"./index-5nd1wtkv.js";
18
- import"./index-pydbnfez.js";
19
- import"./index-qtfmtcrw.js";
19
+ import"./index-p44jnjfr.js";
20
+ import"./index-1xqq3va9.js";
20
21
  import"./index-7md2g9vw.js";
21
22
  import"./index-tvehn2sp.js";
22
- import"./index-j237xtew.js";
23
+ import"./index-deckcwbg.js";
23
24
  import {
24
25
  CloudScript2
25
- } from "./index-hsadfb6c.js";
26
+ } from "./index-c9rfak6r.js";
26
27
  import {
27
28
  writeOption,
28
29
  oneNativeTargetOption,
@@ -33,8 +34,7 @@ import {
33
34
  hostOption,
34
35
  subspaceOption
35
36
  } from "./index-mdjc93e1.js";
36
- import"./index-35hc95h5.js";
37
- import"./index-665zp9rs.js";
37
+ import"./index-f9118j70.js";
38
38
 
39
39
  // pkgs/@akanjs/cli/cloud/cloud.command.ts
40
40
  var localRegistryUrl = () => process.env.AKAN_NPM_REGISTRY ?? "http://127.0.0.1:4873";
@@ -0,0 +1,24 @@
1
+ // @bun
2
+ import {
3
+ CloudScript2
4
+ } from "./index-c9rfak6r.js";
5
+ import"./index-hagw9c94.js";
6
+ import"./index-1xqq3va9.js";
7
+ import"./index-f9118j70.js";
8
+ import"./index-p44jnjfr.js";
9
+ import"./index-deckcwbg.js";
10
+ import"./index-ex35dg39.js";
11
+ import"./index-9h0z0tjr.js";
12
+ import"./index-551gh8h2.js";
13
+ import"./index-m9jj544v.js";
14
+ import"./index-g5px5pxd.js";
15
+ import"./index-7md2g9vw.js";
16
+ import"./index-6mprvdt8.js";
17
+ import"./index-5nd1wtkv.js";
18
+ import"./index-6nqnqzv1.js";
19
+ import"./index-gxqvev8w.js";
20
+ import"./index-tvehn2sp.js";
21
+ import"./index-52w0fvh8.js";
22
+ export {
23
+ CloudScript2 as CloudScript
24
+ };
@@ -4,9 +4,9 @@ import {
4
4
  runner,
5
5
  script,
6
6
  command
7
- } from "./index-jw1zm273.js";
7
+ } from "./index-g5px5pxd.js";
8
8
  import"./index-52w0fvh8.js";
9
- import"./index-va06nr10.js";
9
+ import"./index-gxqvev8w.js";
10
10
  import {
11
11
  akanCodeDefaultModel2,
12
12
  CodeAgentStreamPrinter2
@@ -19,7 +19,7 @@ class CodeRunner extends runner("code") {
19
19
  async serve(options, listen) {
20
20
  await import("./consoleToStderr-h5bryj94.js");
21
21
  const [{ CodeAgent }, { CodeAgentRpcHost }, { CodeAgentRpcListener }] = await Promise.all([
22
- import("./CodeAgent-n3tzjm91.js"),
22
+ import("./CodeAgent-fee0pnwp.js"),
23
23
  import("./CodeAgentRpcHost-9g27hmer.js"),
24
24
  import("./CodeAgentRpcListener-7p7z5dd7.js")
25
25
  ]);
@@ -34,8 +34,8 @@ class CodeRunner extends runner("code") {
34
34
  }
35
35
  async tui(options, seed) {
36
36
  const [{ CodeAgent }, { CodeTui }] = await Promise.all([
37
- import("./CodeAgent-n3tzjm91.js"),
38
- import("./CodeTui-fnm9ft4d.js")
37
+ import("./CodeAgent-fee0pnwp.js"),
38
+ import("./CodeTui-xh71b2k8.js")
39
39
  ]);
40
40
  const agentOptions = await CodeRunner.#agentOptions(options, false);
41
41
  let resume = options.resume;
@@ -67,7 +67,7 @@ class CodeRunner extends runner("code") {
67
67
  }
68
68
  }
69
69
  async run(prompt, options) {
70
- const { CodeAgent } = await import("./CodeAgent-n3tzjm91.js");
70
+ const { CodeAgent } = await import("./CodeAgent-fee0pnwp.js");
71
71
  const agent = await CodeAgent.create(await CodeRunner.#agentOptions(options, false));
72
72
  const printer = new CodeAgentStreamPrinter2({ json: options.json, thinking: options.thinking });
73
73
  agent.on((event) => printer.print(event));
@@ -1 +1 @@
1
- {"byCommand":{"create-workspace":"workspace","generate-agent-rules":"workspace","lint":"workspace","lint-all":"workspace","machine-keygen":"workspace","sync-all":"workspace","init":"workspace","agent":"agent","code":"code","create-application":"application","remove-application":"application","plan-slice":"application","sync":"application","script":"application","console":"application","logs":"application","build":"application","b":"application","typecheck":"application","t":"application","test":"application","build-ios":"application","bi":"application","build-android":"application","ba":"application","build-desktop":"application","bd":"application","start":"application","s":"application","start-ios":"application","si":"application","start-android":"application","sa":"application","start-desktop":"application","sd":"application","release-ios":"application","release-android":"application","pack-update":"application","update-keygen":"application","publish-update":"application","dbup":"application","db-export":"application","db-import":"application","dbdown":"application","create-library":"library","remove-library":"library","sync-library":"library","library-status":"library","install-library":"library","start-registry":"localRegistry","reset-registry":"localRegistry","smoke-registry":"localRegistry","version":"package","create-package":"package","remove-package":"package","sync-package":"package","build-package":"package","verify-dist-package":"package","verify-akan-publish-packages":"package","create-module":"module","remove-module":"module","create-service":"module","create-view":"module","create-unit":"module","create-template":"module","create-crud-page":"page","context":"context","doctor":"context","mcp-install":"context","mcp":"context","mcp-call":"context","login":"cloud","logout":"cloud","deploy-akan":"cloud","test-platforms":"cloud","update":"cloud","push-update":"cloud","register-binary":"cloud","upload-secret":"cloud","list-secrets":"cloud","remove-secret":"cloud","download-env":"cloud","upload-env":"cloud","subspace":"subspace","guideline":"guideline","create-scalar":"scalar","remove-scalar":"scalar","create-ui":"primitive","add-field":"primitive","add-enum-field":"primitive","quality":"quality","repair":"repair","workflow":"workflow","pipeline":"pipeline","tunnel":"tunnel"}}
1
+ {"byCommand":{"create-workspace":"workspace","generate-agent-rules":"workspace","lint":"workspace","lint-all":"workspace","machine-keygen":"workspace","sync-all":"workspace","init":"workspace","agent":"agent","code":"code","create-application":"application","remove-application":"application","plan-slice":"application","sync":"application","script":"application","migrate":"application","create-migration":"application","console":"application","logs":"application","build":"application","b":"application","typecheck":"application","t":"application","test":"application","build-ios":"application","bi":"application","build-android":"application","ba":"application","build-desktop":"application","bd":"application","start":"application","s":"application","start-ios":"application","si":"application","start-android":"application","sa":"application","start-desktop":"application","sd":"application","release-ios":"application","release-android":"application","pack-update":"application","update-keygen":"application","publish-update":"application","dbup":"application","db-export":"application","db-import":"application","dbdown":"application","create-library":"library","remove-library":"library","sync-library":"library","library-status":"library","install-library":"library","start-registry":"localRegistry","reset-registry":"localRegistry","smoke-registry":"localRegistry","version":"package","create-package":"package","remove-package":"package","sync-package":"package","build-package":"package","verify-dist-package":"package","verify-akan-publish-packages":"package","create-module":"module","remove-module":"module","create-service":"module","create-view":"module","create-unit":"module","create-template":"module","create-crud-page":"page","context":"context","doctor":"context","mcp-install":"context","mcp":"context","mcp-call":"context","login":"cloud","logout":"cloud","deploy-akan":"cloud","test-platforms":"cloud","update":"cloud","push-update":"cloud","register-binary":"cloud","upload-secret":"cloud","list-secrets":"cloud","remove-secret":"cloud","download-env":"cloud","upload-env":"cloud","subspace":"subspace","guideline":"guideline","create-scalar":"scalar","remove-scalar":"scalar","create-ui":"primitive","add-field":"primitive","add-enum-field":"primitive","quality":"quality","repair":"repair","workflow":"workflow","pipeline":"pipeline","tunnel":"tunnel"}}
@@ -2,28 +2,28 @@
2
2
  import {
3
3
  Workspace,
4
4
  command
5
- } from "./index-jw1zm273.js";
5
+ } from "./index-g5px5pxd.js";
6
6
  import"./index-52w0fvh8.js";
7
- import"./index-va06nr10.js";
7
+ import"./index-gxqvev8w.js";
8
8
  import"./index-hj6w4ka1.js";
9
- import"./index-trpasv9q.js";
10
- import"./index-5edzv8fn.js";
11
- import"./index-d72hfmdm.js";
12
- import"./index-vk0pa0mn.js";
9
+ import"./index-5m0s0gdv.js";
10
+ import"./index-tbmtmkhx.js";
11
+ import"./index-cq5x7a9k.js";
12
+ import"./index-ex35dg39.js";
13
13
  import"./index-m9jj544v.js";
14
- import"./index-g1mbppa9.js";
15
- import"./index-192ha4xh.js";
14
+ import"./index-551gh8h2.js";
15
+ import"./index-6mprvdt8.js";
16
+ import"./index-6nqnqzv1.js";
16
17
  import"./index-zzvvc845.js";
17
- import"./index-j4mkhz93.js";
18
- import"./index-86jt2a0e.js";
19
- import"./index-fmzcs8v6.js";
20
- import"./index-awbdfcf2.js";
21
- import"./index-1p98exm2.js";
22
- import"./index-1xj2t7cb.js";
18
+ import"./index-t8npm331.js";
19
+ import"./index-3xhak9e0.js";
20
+ import"./index-1bhv9dh4.js";
21
+ import"./index-rp9anyeb.js";
22
+ import"./index-94jq9cbz.js";
23
+ import"./index-85h3dhe0.js";
23
24
  import {
24
25
  ContextScript
25
- } from "./index-4mhy6qme.js";
26
- import"./index-665zp9rs.js";
26
+ } from "./index-7xy30jev.js";
27
27
 
28
28
  // pkgs/@akanjs/cli/context/context.command.ts
29
29
  class ContextCommand extends command("context", [ContextScript], ({ public: target }) => ({
@@ -0,0 +1,25 @@
1
+ // @bun
2
+ import {
3
+ ContextRunner2
4
+ } from "./index-cq5x7a9k.js";
5
+ import"./index-85h3dhe0.js";
6
+ import"./index-94jq9cbz.js";
7
+ import"./index-rp9anyeb.js";
8
+ import"./index-t8npm331.js";
9
+ import"./index-1bhv9dh4.js";
10
+ import"./index-3xhak9e0.js";
11
+ import"./index-ex35dg39.js";
12
+ import"./index-551gh8h2.js";
13
+ import"./index-m9jj544v.js";
14
+ import"./index-tbmtmkhx.js";
15
+ import"./index-5m0s0gdv.js";
16
+ import"./index-zzvvc845.js";
17
+ import"./index-g5px5pxd.js";
18
+ import"./index-6mprvdt8.js";
19
+ import"./index-6nqnqzv1.js";
20
+ import"./index-gxqvev8w.js";
21
+ import"./index-hj6w4ka1.js";
22
+ import"./index-52w0fvh8.js";
23
+ export {
24
+ ContextRunner2 as ContextRunner
25
+ };
@@ -2,9 +2,9 @@
2
2
  import {
3
3
  script,
4
4
  command
5
- } from "./index-jw1zm273.js";
5
+ } from "./index-g5px5pxd.js";
6
6
  import"./index-52w0fvh8.js";
7
- import"./index-va06nr10.js";
7
+ import"./index-gxqvev8w.js";
8
8
  import {
9
9
  Prompter2
10
10
  } from "./index-zzvvc845.js";
@@ -55,7 +55,8 @@ not "fix" it back.
55
55
  the module dictionary's `.error({})` — imported from `"../dict"` on the server, from `"@libs/<lib>/client"` /
56
56
  `"@apps/<app>/client"` in UI. A `throw` is an error; a raw `Error` rejected, returned or stored loses the key and
57
57
  status too (a warning for now). Exempt: tests, `*.constant.ts`, a root `native/` folder (plugins throw
58
- `AkanNativeError`), and `common/**` / `env/**`, which have no legal `Err` import — keep throwing code out of them.
58
+ `AkanNativeError`), `script/migration/**` (an operator reads its message), and `common/**` / `env/**`, which have
59
+ no legal `Err` import — keep throwing code out of them.
59
60
  - **Never import a third-party package** from `page/**`, any barrel, a module logic file
60
61
  (`*.{constant,dictionary,document,service,signal,store}.ts`) or module component
61
62
  (`*.{Template,Unit,Util,View,Zone}.tsx`) — re-export it through a lib first (one-line shims in a lib's `common/`,
@@ -89,6 +90,10 @@ not "fix" it back.
89
90
  - **Never wrap a form setter in a pass-through arrow** — `(v) => st.do.setTypeOnTicket(v)` emits no
90
91
  `data-akan-action` and publishes no agent tool. A wrapper that transforms, adds a statement, or calls `writeOnX`
91
92
  is legal; publish it with an explicit `st.tool`.
93
+ - **Never call an `st` hook conditionally** — `st.use.*`, `st.sel`, `st.ref` and the last step of `st.tool` /
94
+ `st.useState` / `st.expose` are hooks Biome's `useHookAtTopLevel` cannot see. Behind `||` / `&&` / `??`, a ternary,
95
+ an `if`, a loop or a callback, a skipped call shifts every later hook, and production React crashes elsewhere. Read
96
+ each into its own `const` at the top of the component, then combine.
92
97
  - **No deep imports past a barrel**, except cross-module constants (`../map/map.constant`).
93
98
  - **Never import across the client/server boundary** (`apps/**`, `libs/**`). Client files (`ui/`, `webkit/`,
94
99
  `page/`, `*.store.ts`, every `.tsx`) never import a `*.document|dictionary|service|signal.ts`, `srvkit/`, a
@@ -223,8 +228,8 @@ Playbook (warning table, code, checklist: `ssrRule`): ① wrap the interaction a
223
228
  `useEffect(…, [])` load; ④ a store-reading `Zone` holds no markup and delegates to a server `View`; ⑤ hand each
224
229
  promise across — `const { xInitInY, xListInY } = fetch.initXInY(id)`, `xInitInY` to a `Zone`, `xListInY` to
225
230
  `<Load.Stream>` (model instances, server-only) — and `await` only what the shell must contain; ⑥ named `ReactNode`
226
- slots (`Layout.Navbar`); ⑦ derived display logic on `Light<Model>`; ⑧ `getSelf({ unauthorize: "/signin" })` in
227
- `_layout.tsx` (an in-page redirect after I/O; `.config({ ssr: "block" })` for a 3xx); ⑨ CSS (`data-*` +
231
+ slots (`Layout.Navbar`); ⑦ derived display logic on `Light<Model>`; ⑧ `.guard(() => signedIn())` on
232
+ `_layout.tsx` (a real 3xx before anything renders; `getSelf({ unauthorize })` in a body redirects in-page after I/O); ⑨ CSS (`data-*` +
228
233
  `group-data-[…]`, `<details>`) over client state for visibility; ⑩ heavy islands behind `index_.tsx` + `lazy()`.
229
234
 
230
235
  ## Runtime & Build Configuration
@@ -401,8 +406,9 @@ orchestration in `service`, client state in `store`; `Template` is forms, `Unit`
401
406
  - **MCP (`mcpRule`)**: `/mcp` publishes every guarded endpoint by default; `mcp: false` (or a `slice()` `mcp` map
402
407
  mirroring `guards`) is curation, not authorization. `guards: [Every, Person]` reserves an act for a person;
403
408
  `.with(AgentCall)` narrows an agent's call. Settings are `option.setMcp` in `lib/option.ts`; `JWT_SECRET` is
404
- required outside `local`. Never make a refusal message more helpful. Every entry needs a `.desc()`; publish a
405
- screen with `page().prompt(name, description)`.
409
+ required outside `local`. Never make a refusal message more helpful. Every entry needs a `.desc()`; brief a
410
+ screen with `page().prompt(name, description)`, and publish one component a host draws with
411
+ `page().app(name, description, load)` — a read-only tool whose `load` may only query.
406
412
  - **In-page agent (`agentRule`)**: mount `<Agent.Chat />` once in a layout; it never executes tools and refuses
407
413
  every call until `option.setAgentAccess(<guard>)`; the LLM is `option.setLlm({ apiKey, model, host })`, never env.
408
414
  The surface is what components declare — `st.tool(…).exec(fn)` beside its control, `st.use` / `st.sel` /
@@ -460,15 +466,15 @@ orchestration in `service`, client state in `store`; `Template` is forms, `Unit`
460
466
 
461
467
  ## Akan Page Routing (`apps/**/page/**`)
462
468
 
463
- Full contract — heads, CSR root layouts, typed params, lib pages, `devOnly`: `pageRule`.
469
+ Full contract — guards, apps, heads, CSR root layouts, typed params, lib pages, `devOnly`: `pageRule`.
464
470
 
465
471
  - `page/` holds `.tsx` route modules only: `<routeName>.tsx` or `_index.tsx`, `_layout.tsx`, `_overrides.tsx` — no
466
472
  other `_*.tsx`, helpers, `.ts` / `.js` files, or uppercase filenames. `[id]` is a dynamic segment, `(group)` a
467
473
  route group.
468
474
  - **A route file exports one chain** — `page()`, `layout()` in a `_layout.tsx`, `rootLayout()` in a root
469
- `_layout.tsx` — and every setting is a stage (`.param`, `.search`, `.config`, `.head`, `.loading`; `.notFound` /
470
- `.error` on layouts; `.fonts` / `.theme` / `.manifest` / … on the root; `.prompt` on a page). A named export
471
- beside it fails the build.
475
+ `_layout.tsx` — and every setting is a stage (`.param`, `.search`, `.config`, `.guard`, `.head`, `.loading`;
476
+ `.notFound` / `.error` on layouts; `.fonts` / `.theme` / `.manifest` / … on the root; `.prompt` / `.app` on a page).
477
+ A named export beside it fails the build.
472
478
  - **Name every `[x]` segment with `.param("x", Type)`** and read query keys only via `.search("k", Type)`; values
473
479
  arrive typed. `lang` is never declared — every stage receives it.
474
480
  - `.head()` takes JSX or a function returning it — never a metadata object; deeper heads replace by tag identity,
@@ -484,18 +490,19 @@ Full contract — heads, CSR root layouts, typed params, lib pages, `devOnly`: `
484
490
  export default page()
485
491
  .param("orgId", ID)
486
492
  .config({ transition: "stack" })
493
+ .guard(() => signedIn())
487
494
  .render(({ orgId }) => {
488
495
  const { l } = usePage();
489
- getSelf({ unauthorize: "/signin" });
490
496
  const { taskInitInOrg } = fetch.initTaskInOrg(orgId);
491
497
  return <Task.Zone.Card init={taskInitInOrg} prefix={`/org/${orgId}`} />;
492
498
  });
493
499
  ```
494
500
 
495
- - `.render()` gets the declared args flat and typed (no `PageProps`, no `loader=` prop). Order: `usePage()`, auth,
496
- fetch, return. Hand `fetch.init*` / `view*` / `edit*` fields to sections unawaited; await only what the shell reads
501
+ - `.render()` gets the declared args flat and typed (no `PageProps`, no `loader=` prop). Order: `usePage()`, fetch,
502
+ return; auth is the chain's `.guard()`, which runs before anything renders. Hand `fetch.init*` / `view*` / `edit*` fields to sections unawaited; await only what the shell reads
497
503
  (title, redirect, link id) in one `Promise.all`.
498
- - Gate auth at `_layout.tsx` (repeating `getSelf` in the page is fine). `async` only when the body awaits; the
504
+ - Gate auth with `.guard(() => signedIn())` (`@libs/shared/webkit`) at `_layout.tsx`, and repeat it on a page that
505
+ needs more; it is a courtesy, the endpoint guards are the gate. `getSelf({ unauthorize })` in a body still works. `async` only when the body awaits; the
499
506
  callback is not a React component, so it takes no name and no return type. No `useState`, `useEffect`, or
500
507
  comments in page files.
501
508
 
@@ -551,6 +558,28 @@ export default page()
551
558
  barrel holds only `export *` lines). `ui/<Folder>/index_.tsx` is the `"use client"` + `lazy()` boundary beside a
552
559
  server-safe `index.tsx` — merging the pair breaks RSC.
553
560
 
561
+ ## Data Migrations (`apps/*/script/migration/**`)
562
+
563
+ A change that reshapes stored documents ships a migration: `akan create-migration <name> <app>` writes
564
+ `script/migration/<yyyyMMddHHmm>_<name>.ts`, a default-exported `migration(title)` from `akanjs/server`, which
565
+ `akan migrate <app>` runs locally and `bun main.js ops migrate` in a built container (the `cheatsheet/dev/migration`
566
+ docs page).
567
+
568
+ - The new code reads both shapes until every environment has applied it — a deploy serves traffic first.
569
+ - Write only through `table(refName)`, never a service, a document or raw `sql` — a service write runs the model's
570
+ hooks, and none of them reaches the change log a rollback reverts. Call nothing outside the database.
571
+ - `plan` reads only and must hash the same on unchanged data: a timestamp, `createId()` or random value in it makes
572
+ every `apply --expect <planHash>` refuse as `planChanged`.
573
+ - Past about five seconds on SQLite, an apply's one transaction makes the live server's writes fail. Take
574
+ `.config({ transaction: false })`, which commits each `rewrite` batch and resumes a `partial` run from the top of
575
+ `apply` — so a second run must change nothing (a `where` the new shape no longer matches).
576
+ - `$ne` leaves out rows whose path is missing or `null` (match them with `{ path: null }`; `$exists: false` misses a
577
+ stored `null`); `find`, `count` and `rewrite` include removed rows unless `{ withRemoved: false }`; a `table()` write
578
+ leaves `updatedAt` alone.
579
+ - Throw a plain `Error` an operator can act on. Never edit a migration an environment has applied — write another;
580
+ delete it once every environment has, unless its `.rollback(fn)` may still be needed: without the file a rollback
581
+ runs the default undo.
582
+
554
583
  ## Present In The Code — Do Not Imitate
555
584
 
556
585
  Warts in older files — never copy them; when two shapes disagree, follow the newer neighbour: `children: any`