@akanjs/cli 3.0.0-beta.2 → 3.0.0-beta.20

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 (187) hide show
  1. package/.build-stamp +1 -1
  2. package/CodeAgent-awv258wb.js +9 -0
  3. package/CodeAgentRpcHost-p7h6n2hp.js +7 -0
  4. package/CodeAgentRpcListener-7p7z5dd7.js +97 -0
  5. package/CodeTui-1nqh35ez.js +1457 -0
  6. package/README.md +3 -0
  7. package/TunnelShare-scf4e4pd.js +9 -0
  8. package/{agent.command-d2gfxfck.js → agent.command-1s9ag7sb.js} +8 -9
  9. package/akanCode.js +102 -0
  10. package/{application.command-pj2m7584.js → application.command-49hwy6va.js} +51 -78
  11. package/{applicationBuildRunner-kxwbssgn.js → applicationBuildRunner-ybyp97pv.js} +63 -64
  12. package/{applicationReleasePackager-4yasxwv9.js → applicationReleasePackager-esnrphw8.js} +40 -60
  13. package/buildBatch.proc.js +19 -24
  14. package/{capacitorApp-36rbr858.js → capacitorApp-1synz4en.js} +3 -4
  15. package/cloud.command-d7rqtzt9.js +94 -0
  16. package/cloud.script-bkbpcr96.js +19 -0
  17. package/code.command-nn48xzej.js +154 -0
  18. package/commandManifest.json +1 -1
  19. package/consoleToStderr-h5bryj94.js +7 -0
  20. package/context.command-s3mcmvpa.js +48 -0
  21. package/context.runner-k99nb5pk.js +21 -0
  22. package/{dependencyScanner-shs82ynp.js → dependencyScanner-ye2e6pdz.js} +2 -2
  23. package/{devTui-40ggmd99.js → devTui-q7k7bakd.js} +122 -40
  24. package/fileSys-5ngz93ga.js +9 -0
  25. package/guideline.command-sct4qnt5.js +42 -0
  26. package/guidelines/agentRule/agentRule.instruction.md +206 -25
  27. package/guidelines/conventions/conventions.instruction.md +79 -24
  28. package/guidelines/fieldRule/fieldRule.instruction.md +1 -0
  29. package/guidelines/mcpRule/mcpRule.instruction.md +7 -5
  30. package/guidelines/queryRule/queryRule.instruction.md +17 -7
  31. package/guidelines/runtimeRule/runtimeRule.instruction.md +74 -0
  32. package/guidelines/ssrRule/ssrRule.instruction.md +4 -2
  33. package/guidelines/transportRule/transportRule.instruction.md +51 -0
  34. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +66 -3
  35. package/incrementalBuilder.proc.js +31 -48
  36. package/{index-h7yw2z9n.js → index-0bq14vr1.js} +8 -14
  37. package/index-13ffe9wp.js +69 -0
  38. package/index-22d57v4c.js +266 -0
  39. package/{index-fz5q3gd7.js → index-31yr441d.js} +10 -17
  40. package/index-3hx1z96c.js +87 -0
  41. package/index-3sq321ak.js +53 -0
  42. package/{index-kcxmv48c.js → index-3t7g9e4r.js} +45 -79
  43. package/{index-q0y2jq9j.js → index-5b6tavv3.js} +6 -3
  44. package/{index-47pj3aee.js → index-5e0n4hqx.js} +11 -12
  45. package/{index-259dsnz3.js → index-5pc1qrbv.js} +5 -8
  46. package/index-7md2g9vw.js +6 -0
  47. package/index-8mna0947.js +187 -0
  48. package/{index-zry5nz81.js → index-8sf7wmdr.js} +51 -30
  49. package/{index-2tv3fdx4.js → index-9d9bgcx4.js} +342 -765
  50. package/index-9dp031by.js +12 -0
  51. package/{index-ne2qy0nk.js → index-ahemdr5n.js} +12 -12
  52. package/{index-ws5e0j51.js → index-as7xmyz8.js} +40 -24
  53. package/index-axzjaqve.js +1118 -0
  54. package/{index-3d9y066c.js → index-bjwxs904.js} +9 -8
  55. package/index-c6eggbee.js +123 -0
  56. package/index-d2242ksy.js +99 -0
  57. package/{index-a64esmtb.js → index-ddxvdd1p.js} +169 -305
  58. package/{index-92zztqy1.js → index-dy0jx9ay.js} +2 -17
  59. package/{index-pnqbkf5p.js → index-dzf3r49a.js} +6 -2
  60. package/{index-w8kmx1b6.js → index-fgq75haa.js} +198 -290
  61. package/{index-by5gpp8x.js → index-hj6w4ka1.js} +2 -1
  62. package/{index-hwkygn9s.js → index-khpfpcsd.js} +302 -33
  63. package/{index-wt7qrtd4.js → index-mxav6j3c.js} +93 -232
  64. package/{index-gyd220p2.js → index-myhc3c1j.js} +554 -577
  65. package/{index-600zhnve.js → index-nv5976x3.js} +56 -197
  66. package/index-p6pbz9n5.js +25 -0
  67. package/{index-4edzf1gr.js → index-przybvy5.js} +77 -150
  68. package/index-smme4r47.js +49 -0
  69. package/{index-mak3cd28.js → index-w2zdcw3k.js} +137 -255
  70. package/index-wa5jbxj1.js +760 -0
  71. package/{index-v0qh106m.js → index-ww4z397j.js} +527 -723
  72. package/{index-j9yhg404.js → index-xqjwd384.js} +4 -7
  73. package/{index-7737gxcp.js → index-xqpzbab5.js} +107 -241
  74. package/index-xsjh6nzh.js +2729 -0
  75. package/{index-ktb5njgy.js → index-ygn77a5w.js} +47 -99
  76. package/index-ztp3e73t.js +700 -0
  77. package/index.js +23 -22
  78. package/{library.command-nbsky672.js → library.command-1gx04jgn.js} +4 -5
  79. package/{localRegistry.command-yeq57wjr.js → localRegistry.command-zndxj1q6.js} +22 -42
  80. package/{module.command-29vqzrh8.js → module.command-3waddk95.js} +8 -11
  81. package/{package.command-axv0abmn.js → package.command-zrc7br1y.js} +6 -7
  82. package/package.json +14 -5
  83. package/{page.command-vs9s3zrh.js → page.command-vpjgardh.js} +4 -5
  84. package/{primitive.command-cbxmqbtc.js → primitive.command-sz84tk4t.js} +9 -22
  85. package/prompter-ptaa3nk0.js +8 -0
  86. package/{quality.command-gmbs7nws.js → quality.command-g869hafs.js} +203 -376
  87. package/{recipeScanner-fpagtgc1.js → recipeScanner-4b69ybe0.js} +1 -1
  88. package/{repair.command-bqsjptsj.js → repair.command-chsnjvvv.js} +11 -35
  89. package/{routeSourceValidator-apyqw7wk.js → routeSourceValidator-7ycnfz0e.js} +0 -6
  90. package/{scalar.command-6k1vhe9s.js → scalar.command-2v21newx.js} +7 -10
  91. package/skills/akan-code/SKILL.md +130 -0
  92. package/skills/akan-debug/SKILL.md +42 -0
  93. package/skills/akan-deps/SKILL.md +50 -0
  94. package/skills/akan-err/SKILL.md +39 -0
  95. package/skills/akan-module/SKILL.md +45 -0
  96. package/skills/akan-scaffold/SKILL.md +76 -0
  97. package/skills/akan-scalar/SKILL.md +52 -0
  98. package/skills/akan-service/SKILL.md +34 -0
  99. package/skills/akan-store/SKILL.md +67 -0
  100. package/skills/akan-ui/SKILL.md +63 -0
  101. package/skills/akan-validate/SKILL.md +44 -0
  102. package/{subspace.command-fwjfcts7.js → subspace.command-ckcbwfp1.js} +138 -67
  103. package/templates/__scalar/__model__/__model__.abstract.md.template +8 -0
  104. package/templates/appSample/lib/__scalar/workHistory/workHistory.abstract.ts +8 -39
  105. package/templates/appSample/lib/_noti/noti.abstract.ts +6 -29
  106. package/templates/appSample/lib/task/task.abstract.ts +12 -32
  107. package/templates/appSample/lib/task/task.signal.spec.ts +15 -18
  108. package/templates/appSample/lib/task/task.signal.test.ts +15 -1
  109. package/templates/appSample/lib/task/task.signal.ts +1 -1
  110. package/templates/appSample/srvkit/{AuthGuard.ts → guards.ts} +7 -4
  111. package/templates/appSample/srvkit/{SessionInternalArg.ts → internalArgs.ts} +6 -4
  112. package/templates/client.ts +7 -30
  113. package/templates/crudPages/[__model__Id]/edit/page.tsx +2 -1
  114. package/templates/crudPages/[__model__Id]/page.tsx +2 -1
  115. package/templates/crudPages/new/page.tsx +2 -1
  116. package/templates/crudPages/page.tsx +2 -1
  117. package/templates/crudSinglePage/page.tsx +2 -1
  118. package/templates/lib/__lib/lib.dictionary.ts +0 -2
  119. package/templates/lib/__lib/lib.document.ts +0 -2
  120. package/templates/lib/sig.ts +8 -30
  121. package/templates/localDev/docker-compose.yaml.template +3 -14
  122. package/templates/module/__model__.signal.ts +12 -4
  123. package/templates/pkgRoot/tsconfig.json.template +2 -7
  124. package/templates/server.ts +0 -2
  125. package/templates/service/__model__.abstract.md.template +8 -0
  126. package/tunnel.command-kd2yr4fx.js +129 -0
  127. package/{typeChecker-3xgrzc2v.js → typeChecker-px49mezc.js} +1 -1
  128. package/typecheck.proc.js +1 -1
  129. package/workflow.command-44252cqv.js +79 -0
  130. package/{workspace.command-8s050m0h.js → workspace.command-fqcztt5p.js} +77 -109
  131. package/abstractCompactor-mjh5ppsq.js +0 -101
  132. package/cloud.command-jshwdq22.js +0 -93
  133. package/context.command-ez8a0zyz.js +0 -80
  134. package/devTuiView-c08ccbat.js +0 -9
  135. package/getDirname-dr3jz1xg.js +0 -7
  136. package/guideline.command-xmqwx8zm.js +0 -359
  137. package/guidelines/agentRule/agentRule.generate.json +0 -31
  138. package/guidelines/componentRule/componentRule.generate.json +0 -31
  139. package/guidelines/conventions/conventions.generate.json +0 -25
  140. package/guidelines/cssRule/cssRule.generate.json +0 -31
  141. package/guidelines/docPageRule/docPageRule.generate.json +0 -31
  142. package/guidelines/docPageRule/docPageRule.instruction.md +0 -25
  143. package/guidelines/docSyncRule/docSyncRule.generate.json +0 -31
  144. package/guidelines/docSyncRule/docSyncRule.instruction.md +0 -25
  145. package/guidelines/enumConstant/enumConstant.generate.json +0 -31
  146. package/guidelines/enumConstant/enumConstant.instruction.md +0 -28
  147. package/guidelines/fieldRule/fieldRule.generate.json +0 -31
  148. package/guidelines/framework/framework.generate.json +0 -32
  149. package/guidelines/mcpRule/mcpRule.generate.json +0 -35
  150. package/guidelines/modelConstant/modelConstant.generate.json +0 -32
  151. package/guidelines/modelDictionary/modelDictionary.generate.json +0 -32
  152. package/guidelines/modelDocument/modelDocument.generate.json +0 -31
  153. package/guidelines/modelService/modelService.generate.json +0 -31
  154. package/guidelines/modelSignal/modelSignal.generate.json +0 -31
  155. package/guidelines/modelStore/modelStore.generate.json +0 -31
  156. package/guidelines/modelTemplate/modelTemplate.generate.json +0 -31
  157. package/guidelines/modelUnit/modelUnit.generate.json +0 -31
  158. package/guidelines/modelUtil/modelUtil.generate.json +0 -31
  159. package/guidelines/modelView/modelView.generate.json +0 -31
  160. package/guidelines/modelZone/modelZone.generate.json +0 -31
  161. package/guidelines/moduleCodegen/moduleCodegen.generate.json +0 -31
  162. package/guidelines/moduleCodegen/moduleCodegen.instruction.md +0 -28
  163. package/guidelines/moduleOverview/moduleOverview.generate.json +0 -31
  164. package/guidelines/queryRule/queryRule.generate.json +0 -31
  165. package/guidelines/recipeRule/recipeRule.generate.json +0 -31
  166. package/guidelines/runtimeRule/runtimeRule.generate.json +0 -25
  167. package/guidelines/scalarConstant/scalarConstant.generate.json +0 -32
  168. package/guidelines/scalarDictionary/scalarDictionary.generate.json +0 -32
  169. package/guidelines/scalarModule/scalarModule.generate.json +0 -31
  170. package/guidelines/sharedUiUsage/sharedUiUsage.generate.json +0 -31
  171. package/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +0 -25
  172. package/guidelines/ssrRule/ssrRule.generate.json +0 -31
  173. package/guidelines/transportRule/transportRule.generate.json +0 -31
  174. package/guidelines/utilUiUsage/utilUiUsage.generate.json +0 -31
  175. package/guidelines/utilUiUsage/utilUiUsage.instruction.md +0 -25
  176. package/guidelines/workspaceOnboarding/workspaceOnboarding.generate.json +0 -24
  177. package/guidelines/workspaceRecipes/workspaceRecipes.generate.json +0 -33
  178. package/index-2hq52jq3.js +0 -465
  179. package/index-6wwzs1bc.js +0 -7
  180. package/index-8pm30m73.js +0 -841
  181. package/index-kn1h7p1x.js +0 -560
  182. package/index-meh558jy.js +0 -65
  183. package/index-rwg2aa4f.js +0 -229
  184. package/templates/__scalar/__model__/__model__.abstract.md +0 -28
  185. package/templates/module/__model__.abstract.md +0 -28
  186. package/templates/service/__model__.abstract.md +0 -28
  187. package/workflow.command-nwpcdc8p.js +0 -107
@@ -3,7 +3,7 @@ import {
3
3
  collectRecipeSources2,
4
4
  scanRecipes2,
5
5
  findInlineRecipeDuplicates2
6
- } from "./index-by5gpp8x.js";
6
+ } from "./index-hj6w4ka1.js";
7
7
  export {
8
8
  collectRecipeSources2 as collectRecipeSources,
9
9
  findInlineRecipeDuplicates2 as findInlineRecipeDuplicates,
@@ -3,34 +3,21 @@ import {
3
3
  Workspace,
4
4
  script,
5
5
  command
6
- } from "./index-mak3cd28.js";
7
- import"./index-q0y2jq9j.js";
8
- import"./index-2tv3fdx4.js";
9
- import"./index-6wwzs1bc.js";
10
- import"./index-by5gpp8x.js";
11
- import"./index-gyd220p2.js";
12
- import"./index-ktb5njgy.js";
6
+ } from "./index-w2zdcw3k.js";
7
+ import"./index-5b6tavv3.js";
8
+ import"./index-9d9bgcx4.js";
9
+ import"./index-hj6w4ka1.js";
10
+ import"./index-myhc3c1j.js";
11
+ import"./index-ygn77a5w.js";
13
12
  import {
14
13
  RepairRunner
15
- } from "./index-fz5q3gd7.js";
14
+ } from "./index-31yr441d.js";
16
15
 
17
16
  // pkgs/@akanjs/cli/repair/repair.script.ts
18
17
  import { Logger } from "akanjs/common";
19
18
  class RepairScript extends script("repair", [RepairRunner]) {
20
- async repair(kind, {
21
- workspace,
22
- app = null,
23
- module = null,
24
- target = null,
25
- format = "markdown"
26
- }) {
27
- Logger.rawLog(await this.repairRunner.repair(kind, {
28
- workspace,
29
- app,
30
- module,
31
- target,
32
- format
33
- }));
19
+ async repair(kind, options) {
20
+ Logger.rawLog(await this.repairRunner.repair(kind, options));
34
21
  }
35
22
  }
36
23
 
@@ -39,12 +26,7 @@ class RepairCommand extends command("repair", [RepairScript], ({ public: target
39
26
  repair: target({ desc: "Run a narrow Akan repair command and return a structured report" }).arg("kind", String, {
40
27
  desc: "generated, format, imports, dictionary, or module-shape",
41
28
  enum: ["generated", "format", "imports", "dictionary", "module-shape"]
42
- }).with(Workspace).option("format", String, {
43
- desc: "output format",
44
- flag: "o",
45
- default: "markdown",
46
- enum: ["markdown", "json"]
47
- }).option("app", String, {
29
+ }).with(Workspace).option("format", String, { desc: "output format", flag: "o", default: "markdown", enum: ["markdown", "json"] }).option("app", String, {
48
30
  desc: "target app or library for generated/dictionary/module-shape repair",
49
31
  nullable: true
50
32
  }).option("module", String, { desc: "target module for dictionary/module-shape repair", nullable: true }).option("target", String, {
@@ -52,13 +34,7 @@ class RepairCommand extends command("repair", [RepairScript], ({ public: target
52
34
  desc: "target app, library, or package for format/imports repair",
53
35
  nullable: true
54
36
  }).exec(async function(kind, workspace, format, app, module, targetName) {
55
- await this.repairScript.repair(kind, {
56
- workspace,
57
- format,
58
- app,
59
- module,
60
- target: targetName
61
- });
37
+ await this.repairScript.repair(kind, { workspace, format, app, module, target: targetName });
62
38
  })
63
39
  })) {
64
40
  }
@@ -57,12 +57,6 @@ class RouteSourceValidator {
57
57
  if (exported.has("head") && exported.has("generateHead")) {
58
58
  throw new Error(`[route-convention] head and generateHead cannot both be exported in ${filePath}`);
59
59
  }
60
- if (!options.rootLayout && (exported.has("head") || exported.has("generateHead")) && (exported.has("metadata") || exported.has("generateMetadata"))) {
61
- throw new Error(`[route-convention] head/generateHead and metadata/generateMetadata cannot both be exported in ${filePath}`);
62
- }
63
- if (exported.has("metadata") && exported.has("generateMetadata")) {
64
- throw new Error(`[route-convention] metadata and generateMetadata cannot both be exported in ${filePath}`);
65
- }
66
60
  const chain = RouteSourceValidator.#readChain(sourceFile, filePath);
67
61
  if (!chain)
68
62
  return { devOnly: RouteSourceValidator.#readDevOnly(sourceFile, filePath) };
@@ -2,25 +2,22 @@
2
2
  import {
3
3
  Sys,
4
4
  command
5
- } from "./index-mak3cd28.js";
6
- import"./index-q0y2jq9j.js";
7
- import"./index-2tv3fdx4.js";
8
- import"./index-6wwzs1bc.js";
5
+ } from "./index-w2zdcw3k.js";
6
+ import"./index-5b6tavv3.js";
7
+ import"./index-9d9bgcx4.js";
9
8
  import {
10
9
  renderPrimitiveReport
11
- } from "./index-gyd220p2.js";
12
- import"./index-kn1h7p1x.js";
13
- import"./index-h7yw2z9n.js";
10
+ } from "./index-myhc3c1j.js";
14
11
  import {
15
12
  ScalarScript
16
- } from "./index-rwg2aa4f.js";
13
+ } from "./index-3sq321ak.js";
17
14
 
18
15
  // pkgs/@akanjs/cli/scalar/scalar.command.ts
19
16
  import { Logger, lowerlize } from "akanjs/common";
20
17
  class ScalarCommand extends command("scalar", [ScalarScript], ({ public: target }) => ({
21
- createScalar: target({ desc: "Create a new scalar type (simple data model without DB)" }).arg("scalarName", String, { desc: "name of scalar" }).with(Sys).option("ai", Boolean, { default: false, desc: "use ai to create scalar" }).option("format", String, { flag: "o", desc: "output format", default: "markdown", enum: ["markdown", "json"] }).exec(async function(scalarName, sys, ai, format) {
18
+ createScalar: target({ desc: "Create a new scalar type (simple data model without DB)" }).arg("scalarName", String, { desc: "name of scalar" }).with(Sys).option("format", String, { flag: "o", desc: "output format", default: "markdown", enum: ["markdown", "json"] }).exec(async function(scalarName, sys, format) {
22
19
  const name = lowerlize(scalarName.replace(/ /g, ""));
23
- const report = ai ? await this.scalarScript.createScalarWithAi(sys, name) : await this.scalarScript.createScalar(sys, name);
20
+ const report = await this.scalarScript.createScalar(sys, name);
24
21
  Logger.rawLog(renderPrimitiveReport(report, format));
25
22
  }),
26
23
  removeScalar: target({ desc: "Remove a scalar type from an app or library" }).arg("scalarName", String, { desc: "name of scalar" }).with(Sys).exec(async function(scalarName, sys) {
@@ -0,0 +1,130 @@
1
+ ---
2
+ name: akan-code
3
+ description: "Answer a question about `akan code` itself — how to add or remove an MCP server, sign one in, switch model, fork or resume a session, what the slash commands and keys are, and where its files live. Read this before telling anyone how to use this tool."
4
+ ---
5
+
6
+ # akan code — the manual
7
+
8
+ This is the tool the user is talking to right now. When they ask how to do something *with it* — rather than
9
+ with their code — answer from here, and quote the exact gesture: the slash command to type, or the file to
10
+ edit. Do not guess a command; everything this tool offers is listed below.
11
+
12
+ You cannot type a slash command yourself. They are the host's, not yours — say which one to type. You *can*
13
+ edit the files named below, which is the useful half of most of these answers: write the change, then say
14
+ which command makes it take effect.
15
+
16
+ ## MCP servers
17
+
18
+ Declared in **`~/.akan/code/mcp.json`**, which every repo reads, or in this repo's **`.akan/code/mcp.json`**,
19
+ which wins a name both declare — in the same `mcpServers` shape Claude, Cursor and VS Code already write, so a
20
+ block can be pasted across rather than translated. VS Code's `servers` spelling is read too, and
21
+ whichever key the file already uses is the one a write goes back into.
22
+
23
+ ```jsonc
24
+ {
25
+ "mcpServers": {
26
+ "github": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"] },
27
+ "linear": { "url": "https://mcp.linear.app/sse" },
28
+ "internal": { "url": "https://…/mcp", "headers": { "x-api-key": "…" } },
29
+ "old": { "command": "x", "disabled": true }
30
+ }
31
+ }
32
+ ```
33
+
34
+ A `url` is an http server; anything else is a command with its argv. `env` passes variables to a stdio
35
+ server, `headers` goes on every http request (a server behind a static token needs nothing else), and
36
+ `disabled: true` keeps an entry without connecting it.
37
+
38
+ From the prompt:
39
+
40
+ ```
41
+ /mcp what is declared, what connected, and how many tools each gave
42
+ /mcp <name> the tools that one server published
43
+ /mcp add <name> <command> [args…]
44
+ /mcp add <name> <https://…>
45
+ /mcp add --local <name> … this repo's file only, not ~/.akan/code/mcp.json
46
+ /mcp remove <name> this repo's file first, else ~/.akan/code/mcp.json
47
+ /mcp remove --local <name>
48
+ /mcp login <name> OAuth, in the browser
49
+ /mcp logout <name> forget the token, leaving the server declared
50
+ /mcp reload reopen this session so the file takes effect
51
+ ```
52
+
53
+ **A server added now is not reachable until the session reloads.** The tool allowlist is fixed when the
54
+ session is created, so `add`, `remove`, `login` and `logout` all reload by themselves — a session that has
55
+ said nothing yet has nothing on disk to reopen, and says so. If you edit `mcp.json` yourself, tell the user to
56
+ run `/mcp reload`.
57
+
58
+ `/mcp remove` on a name both files declare takes this repo's entry and leaves the home file's in force; its
59
+ notice says so, and running it again removes that one too.
60
+
61
+ Sign-in is discovered, not configured: the server's `401` names its resource metadata, that names the
62
+ authorization server, and most hosted servers register a client on demand — so a url is usually the whole
63
+ entry. For a provider that issues client ids by hand, add `"oauth": { "clientId": "…", "scope": "…" }`.
64
+ Tokens are stored per server in `~/.akan/code/mcpAuth.json` at mode 0600, never in the repo, and refreshed
65
+ silently — at connect when one has expired, and mid-session when a server refuses one, after which the call is
66
+ retried once. When a refresh cannot fix it, `/mcp` shows `sign-in needed` and that server's tools answer with
67
+ `/mcp login <name>` until the user signs in; the sign-in reloads the session, which brings the server back.
68
+
69
+ ## Sessions
70
+
71
+ Stored under `.akan/code/sessions` — project history, so a second checkout of the same repo has its own.
72
+
73
+ - `←` at the start of the prompt lists past sessions; enter reopens the chosen one.
74
+ - `akan code --resume <id>` (`-R`) reopens one from the shell.
75
+ - `/fork [name]` continues the conversation twice: the copy takes over here, and the notice names the command
76
+ that reopens the original.
77
+ - `/name <text>` names this one, which is what the session list is read by.
78
+ - `/peers` lists other `akan code` sessions running in this workspace; `/msg <peer> <text>` hands one a
79
+ message.
80
+ - `/clear` wipes the screen and keeps the conversation; `/compact [notes]` shortens what the model carries.
81
+
82
+ ## Model, effort, keys
83
+
84
+ - `/model <provider>/<id>`, e.g. `/model deepseek/deepseek-v4-pro`. `/effort <level>` for how hard it thinks.
85
+ - A provider is authorized by **`<PROVIDER>_API_KEY`** — `DEEPSEEK_API_KEY`, `ANTHROPIC_API_KEY`. The
86
+ workspace's own `.env` is read as well as the environment, and a key found there is used for the run and
87
+ never copied anywhere.
88
+ - Credentials and the model catalogue live in `~/.akan/code/` (`auth.json`, `models.json`). **`AKAN_CODE_HOME`
89
+ moves the whole directory** — for a container with no home, or a checkout that wants its own.
90
+
91
+ ## What the agent reads, and how to change it
92
+
93
+ - Every `AGENTS.md` / `CLAUDE.md` from the workspace root down to the working directory, `.cursorrules`, and
94
+ any `.cursor/rules/*.mdc` that applies unconditionally (`alwaysApply: true`, or no frontmatter at all).
95
+ Edit those to change how this agent behaves in this repo — they are the files the editor beside it reads.
96
+ - Skills: drop a `<name>/SKILL.md` into `.akan/code/skills`. Extensions: `.akan/code/extensions`. Neither is
97
+ read from a home directory, so a session behaves the same in two checkouts.
98
+
99
+ ## Keys
100
+
101
+ ```
102
+ enter send · shift+enter newline · ↑↓ move (history at the edges) · ←→ move
103
+ esc interrupt · pgup/pgdn scroll · ^c quit · tab completes a slash command
104
+ @ completes a file in this repo · wheel scrolls the transcript (hold shift to select text instead)
105
+ cmd+v attaches an image from the clipboard · ^v does too, without the terminal in the way
106
+ ```
107
+
108
+ Most terminals send the same byte for enter and shift+enter, so the key only arrives where the terminal can
109
+ say which was pressed. In VS Code, bind it with `workbench.action.terminal.sendSequence` and a `text` of
110
+ `"\\\u001b\r"`; iTerm2 calls the same thing "Send Text". Either spelling of that sequence works here, and
111
+ the backslash a shell would read as a line continuation never reaches the prompt.
112
+
113
+ ## Starting it
114
+
115
+ ```
116
+ akan code open the session
117
+ akan code "<prompt>" run one turn and print the answer
118
+ akan code -i "<prompt>" open the session with the prompt already sent
119
+ --app <name> narrow the agent to one app
120
+ --profile local|pod|review|web what it may do (default local)
121
+ --model <provider>/<id> --thinking, --json, --rpc, --resume <id>
122
+ ```
123
+
124
+ `review` reads and never writes, loads no project context files, and keeps no session on disk. `pod` has
125
+ nobody in front of it: it cannot ask a question. MCP is off in both.
126
+
127
+ ## The rest of the commands
128
+
129
+ `/help` prints all of this list · `/tools` what this session can call · `/agents` what a sub-agent may be and
130
+ what one may spend · `/thinking` shows or folds the reasoning · `/abort` stops the running turn · `/quit`.
@@ -0,0 +1,42 @@
1
+ ---
2
+ name: akan-debug
3
+ description: "Debug a running Akan app: where the dev-server log is, how to read it, and how to tell a runtime failure from a build one."
4
+ ---
5
+
6
+ # Akan debug
7
+
8
+ ## The log is a file, and that file is the whole session
9
+
10
+ A supervised `akan start` writes **`local/apps/<app>/runtime/dev.log`** — no ANSI, nothing truncated, every
11
+ process of the app in arrival order, including the dev host's own build output, which reaches no other
12
+ file. The previous session is kept beside it as `dev.prev.log`.
13
+
14
+ Read that file. Do not ask for a paste of the terminal: the full-screen view repaints one frame in place, so
15
+ what survives in the scrollback is bordered and truncated to the pane.
16
+
17
+ - `tail -n 200 local/apps/<app>/runtime/dev.log` after an edit, to see what the reload produced.
18
+ - `akan logs <app>` tails a running server with `--level --grep --endpoint --trace --child --role --origin
19
+ --since` and `--json`.
20
+ - The dev server's URL is printed in that log, and the port is allocated rather than fixed — the log is the
21
+ only source for it.
22
+
23
+ ## Which loop you are in
24
+
25
+ - **A type or lint failure** is the `akan-validate` loop. `akan_verify`.
26
+ - **A runtime or SSR failure** is the dev log. The page renders blank, an overlay appears, or a request
27
+ 500s — none of that shows up in a typecheck.
28
+
29
+ If a dev server is already running for the app, do **not** start another. If it looks wedged, surface the
30
+ log tail in your answer rather than killing it.
31
+
32
+ ## Reading a log line
33
+
34
+ Every `Logger` call carries `traceId`, `endpoint` and `origin` alongside the message, so one request's lines
35
+ share a trace — `akan logs <app> --trace <id>` pulls just that request. The level ladder is
36
+ `trace verbose debug info warn error`; `.log()` is deprecated and emits at `info`, which is why a call that
37
+ reads like its own level is not one.
38
+
39
+ ## Before you conclude
40
+
41
+ A change that renders is not a change that passed. Run `akan_verify`, and for a `.tsx` change check
42
+ `akan quality ssr` too — a UI edit that moves markup into a client bundle typechecks perfectly.
@@ -0,0 +1,50 @@
1
+ ---
2
+ name: akan-deps
3
+ description: "Fix an import, dependency, or barrel problem in an Akan workspace — barrels are generated, and a third-party package may not be imported from most files."
4
+ ---
5
+
6
+ # Akan imports, deps and barrels
7
+
8
+ ## Barrels are generated
9
+
10
+ Every `index.ts` under `ui/`, `webkit/`, `srvkit/`, `common/`, `plugin/` and `lib/**` is scanner output, as
11
+ are `cnst.ts`, `db.ts`, `dict.ts`, `sig.ts`, `srv.ts`, `st.ts`, `useClient.ts`, `useServer.ts`, `client.ts`
12
+ and `server.ts`. Do not hand-edit them and do not rely on their exact contents.
13
+
14
+ **If an import "cannot be found" but the file exists, the barrel is stale** — run `akan sync <app-or-lib>`,
15
+ or `repair_generated`. A `ui/<Folder>/index.tsx` that builds a namespace is hand-written source; the
16
+ distinguishing test is that a generated barrel contains nothing but `export * from "./X";` lines.
17
+
18
+ ## Where a dependency is declared
19
+
20
+ Add the package to the `package.json` of the app or lib that imports it —
21
+ `apps/<app>/package.json` or `libs/<lib>/package.json` — then `bun install` from the repo root.
22
+
23
+ ## A third-party package may not be imported from most files
24
+
25
+ `no-import-external-library.grit` refuses a third-party import from `page/**`, from any barrel, and from any
26
+ `*.{constant,dictionary,document,service,signal,store}.ts` or `*.{Template,Unit,Util,View,Zone}.tsx`.
27
+ Re-export the symbol through a lib first. The one-line re-export shims in a lib's `common/`, `webkit/` and
28
+ `ui/` exist for exactly this — they are load-bearing, not cruft.
29
+
30
+ ## Two more import rules the build enforces
31
+
32
+ - **No deep import past a barrel** (`no-deep-internal-import.grit`). Cross-module constant references such as
33
+ `../map/map.constant` are the sanctioned exception.
34
+ - **No import across the client/server boundary.** A client file may not import a `*.document.ts` /
35
+ `*.dictionary.ts` / `*.service.ts` / `*.signal.ts`, `srvkit/`, a package `server` entrypoint, or the `db` /
36
+ `srv` / `sig` / `dict` / `option` / `useServer` barrels. A server file may not import a `*.store.ts`, a
37
+ module component, `ui/`, `webkit/`, a package `client` entrypoint, or `st` / `store` / `useClient`. Shared
38
+ files — `common/` and `*.constant.ts` — are held to **both**. `import type` is erased and stays legal in
39
+ every direction; a mixed value-and-type import is not exempt.
40
+
41
+ ## Aliases
42
+
43
+ `akanjs/*` for framework facets, `@apps/*`, `@libs/*`, `@contract/*`. In `.tsx`, one flat named import from
44
+ the package client path — `import { cnst, fetch, st, usePage } from "@apps/<app>/client"` — never a relative
45
+ `../` import. In backend `.ts`, namespace the generated barrels: `import * as cnst from "../cnst"`.
46
+
47
+ ## Validate
48
+
49
+ `akan_verify`, or `akan sync <app>` then `akan lint <app>` then `akan typecheck <app>`. Raw `tsc` misses the
50
+ generated barrels and reports false errors.
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: akan-err
3
+ description: "Throw errors the Akan way — a typed Err with a dictionary key, never a bare throw new Error. Lint-enforced."
4
+ ---
5
+
6
+ # throw → Err
7
+
8
+ Domain code throws `new Err("<module>.error.<key>")` and registers the key as `[en, ko]` in that module's
9
+ dictionary `.error({})`. `throw new Error(...)` fails the build (`no-throw-raw-error.grit`).
10
+
11
+ ## Getting the import side right
12
+
13
+ This is the common failure. Import `Err` from the source matching the **runtime side of the file**:
14
+
15
+ - server code: `import { Err } from "../dict"`
16
+ - UI: `from "@libs/<lib>/client"` or `from "@apps/<app>/client"`
17
+
18
+ ## Where the rule does not apply
19
+
20
+ The lint rule exempts tests, `*.constant.ts`, `common/**`, and `env/**`. The last two have **no legal `Err`
21
+ import path at all**, so keep throwing code out of them entirely rather than reaching for a workaround.
22
+
23
+ ## Where each error belongs
24
+
25
+ - a state-machine precondition → `document.ts`
26
+ - a cross-document rule → `service.ts`
27
+ - request-level policy → a guard in `signal.ts`
28
+
29
+ Best-effort code returns a sentinel (`null`, `undefined`, `{}`) instead of throwing. `try/catch` is rare and
30
+ always converts an exception into a decision: a guard catches, warns, and returns `false`; an adapter
31
+ catches, logs, and returns `null`. A store action never catches — let the framework toast the `Err`.
32
+ Client-side validation failure is `msg.error("<key>")` plus an early return, never a throw.
33
+
34
+ **A failure another process reported travels as itself.** A server-to-server `fetch.<endpoint>(…, { origin })`
35
+ restores the remote `Err` with its class, key and data. Rethrow it as-is — wrapping it in a `new Error`
36
+ discards what the endpoint chose to say, and a bare `Error` is generalized to "Internal Server Error" on the
37
+ way out.
38
+
39
+ Korean `.error()` messages end in `다.`.
@@ -0,0 +1,45 @@
1
+ ---
2
+ name: akan-module
3
+ description: "Add or change an Akan database module: the constant→dictionary→document→service→signal→store→UI flow and which layer owns what."
4
+ ---
5
+
6
+ # Akan module flow
7
+
8
+ Creating a **new** module? Do not hand-write these files — scaffold with `create-module` first (the
9
+ `akan-scaffold` skill), then fill in the layers below.
10
+
11
+ A stored model flows through layers, one file each under `lib/<model>/`:
12
+
13
+ `constant → dictionary → document → service → signal → store → UI`
14
+
15
+ | file | owns |
16
+ | --- | --- |
17
+ | `<model>.constant.ts` | the five classes, in order: `XInput → XObject → LightX → X → XInsight`. Write `XInsight` even when empty. |
18
+ | `<model>.dictionary.ts` | `[en, ko]` labels and the `Err` keys, in the fixed chain with empty stages still written. |
19
+ | `<model>.document.ts` | `XFilter → X → XModel`. Chain methods validate, mutate, `return this`, and never `save()`. |
20
+ | `<model>.service.ts` | load → chain → `return await ….save()`. Side effects go in `_preUpdate` / `_postCreate`. |
21
+ | `<model>.signal.ts` | `XInternal → XSlice → XEndpoint`, all three declared even when empty. |
22
+ | `<model>.store.ts` | only what `store()` does not already generate — see `akan-store`. |
23
+ | `<Model>.*.tsx` | rendering. `Template` / `Zone` / `Util` are client, `Unit` / `View` are server. |
24
+
25
+ ## The rule most often missed
26
+
27
+ **Display and predicate logic belongs on `Light<Model>`** — `isNew()`, `canWrite(user?)`, `formatTimes()`.
28
+ The Light class is the one both server and client hold, so shared logic lives there instead of in a util
29
+ module. Collection-level helpers go `static` on the full model.
30
+
31
+ ## Rules
32
+
33
+ - New module ⇒ `create-module`. New field / action / list on an existing one ⇒ `add-field` /
34
+ `add-mutation` / `add-slice`. Hand-writing is the fallback, not the default.
35
+ - A module is for data that must be **stored**. Static page content is a page.
36
+ - Keep business decisions in constant, document and service; API exposure in signal; client coordination in
37
+ store; rendering in UI.
38
+ - Never hand-edit a generated registry file — `cnst.ts`, `db.ts`, `dict.ts`, `option.ts`, `sig.ts`, `srv.ts`,
39
+ `st.ts`, `useClient.ts`, `useServer.ts`, and every `index.ts` barrel. They are scanner output; run
40
+ `akan sync <app>` or `repair_generated`.
41
+ - Read the module's `<module>.abstract.md` before changing it, and update it when an invariant or workflow
42
+ changes — not for formatting.
43
+
44
+ Deeper detail per layer is a `get_guideline` call away: `moduleOverview`, `modelConstant`, `modelDocument`,
45
+ `modelService`, `modelSignal`, `modelStore`, `modelDictionary`.
@@ -0,0 +1,76 @@
1
+ ---
2
+ name: akan-scaffold
3
+ description: "Create a new module, scalar, field, mutation, slice, or UI surface — scaffold it with the akan workflow tools (plan_workflow / apply_workflow) instead of writing the files by hand."
4
+ ---
5
+
6
+ # Akan scaffolding workflows (use these BEFORE writing files)
7
+
8
+ Akan generates the conventional file set for you. Creating those files by hand skips the conventions, the
9
+ generated-barrel sync, and the validation chain.
10
+
11
+ ## Step 0 — decide WHAT gets a module, before any tool call
12
+
13
+ List the things the request says must be **stored in the database**. Those, and only those, become modules.
14
+ Everything else is pages, sections, and props.
15
+
16
+ - A page or section whose content you can write as static JSX or props is not an entity. "A self-intro page
17
+ with two detail pages" is pages only — no `profile` module.
18
+ - Never invent a supporting entity (profile, category, tag, author, like) to round out a design. If one looks
19
+ genuinely necessary, say so in your reply and let the user decide.
20
+ - "… plus a comment zone that saves to a database" is exactly one new module: `comment`.
21
+ - Check what exists first (`list_modules`) and extend it when it already fits — `add-field` / `add-slice` /
22
+ `create-ui` beat a whole new module.
23
+ - Build the entire request, at the smallest structure that satisfies it.
24
+
25
+ Then pick the workflow that matches the intent:
26
+
27
+ | The user wants… | workflow |
28
+ | --- | --- |
29
+ | a new database-backed entity (comment, post, todo, product …) | `create-module` |
30
+ | a reusable embedded value object | `create-scalar` |
31
+ | a new field on an existing module | `add-field` |
32
+ | a new field with a closed set of values | `add-enum-field` |
33
+ | a new state-changing action | `add-mutation` |
34
+ | a filtered list, tab, or reusable query | `add-slice` |
35
+ | a View / Unit / Template / Zone / Util for an existing module | `create-ui` |
36
+
37
+ ## The chain
38
+
39
+ Each result names the next call in `next.tool`. Follow it; do not improvise.
40
+
41
+ 1. `plan_workflow({ workflow: "create-module", inputs: { app: "<app>", module: "comment" } })` — read-only.
42
+ Returns `planPath` and `next.tool=apply_workflow`. (`list_workflows` / `explain_workflow` give the names
43
+ and each workflow's inputs.)
44
+ 2. `apply_workflow({ planPath })` — writes the scaffold and syncs the generated barrels. Returns
45
+ `validationTarget`.
46
+ 3. `run_validation({ runIdOrPlan: <validationTarget> })`, or just call `akan_verify`, which runs the whole
47
+ chain over everything the working tree changed.
48
+ 4. **Read each scaffolded file before editing it.** They are a few lines each and they extend base classes
49
+ that already generated the CRUD surface. Read the `akan-store` skill before touching a store or adding
50
+ signal endpoints, or you will redeclare `create<Model>` and hit an "already exists" typecheck error.
51
+ 5. Now fill in: real fields in the constant, invariants in document and service, non-CRUD API in the signal,
52
+ extra state in the store, rendering in the UI. Filling in a scaffold is the job; creating one by hand is
53
+ not.
54
+
55
+ ## Rules
56
+
57
+ - One run per unit of structure: two new entities are two `create-module` runs.
58
+ - `requiresApproval: true` on a plan is a review signal for you, not a permission gate — read
59
+ `predictedChanges`, then apply.
60
+ - Hand-writing files is the fallback, used only when no workflow matches, or when apply reports
61
+ unsupported / no-op / failed diagnostics telling you to act manually. Say which case applied.
62
+ - Never hand-edit a generated file to "finish" a scaffold — use `repair_generated` or `akan sync <app>`.
63
+ - No workflow tools this turn? The same order through bash:
64
+ `akan workflow list` → `akan workflow plan create-module --app <app> --module comment --format json --out <path>`
65
+ → `akan workflow apply <path> --format json`.
66
+
67
+ ## Worked example — "an intro page, two detail pages, and a comment zone with a database"
68
+
69
+ 0. What must be stored? Only the comments. One module, `comment`. The three pages are static content.
70
+ 1. `plan_workflow({ workflow: "create-module", inputs: { app: "<app>", module: "comment" } })`
71
+ 2. `apply_workflow({ planPath })` — `lib/comment/*` exists, barrels synced.
72
+ 3. Read the scaffolded files. Edit `comment.constant.ts` for the real shape. The store's CRUD already exists;
73
+ leave the store body empty unless you need extra state.
74
+ 4. Write the pages and the comment UI against the generated actions — `st.do.createComment`,
75
+ `st.do.initCommentInPublic`, `st.use.commentListInPublic`.
76
+ 5. `akan_verify` until clean.
@@ -0,0 +1,52 @@
1
+ ---
2
+ name: akan-scalar
3
+ description: "Create an embedded value object (scalar) under lib/__scalar/, or add a relation field to another model — including which cascade direction is which."
4
+ ---
5
+
6
+ # Akan scalars and relations
7
+
8
+ ## Scalars
9
+
10
+ A scalar is an embedded value object with no collection of its own. It lives in `lib/__scalar/<name>/`, is
11
+ composed into models with `scalar(...)`, and its dictionary is a `scalarDictionary`. Create one with the
12
+ `create-scalar` workflow; its UI surface is limited to `<Scalar>.Template.tsx` and `<Scalar>.Unit.tsx`.
13
+
14
+ ## Relations
15
+
16
+ A reference to another model is `field(Model)`, or `field([Model])` for many. Files and images are a
17
+ relation to the `File` model — `image: field(File).optional()` — never an `Upload` field; `Upload` is a
18
+ signal-body primitive only. The store then generates `upload<Field>On<Model>(fileList)` for you.
19
+
20
+ **Hydrated vs raw.** A server query returns a hydrated `cnst.<Model>` instance with `set` / `save` /
21
+ `refresh`. A client `fetch` result is raw plain data with the functions stripped. Code that works in a
22
+ service and fails in a store is usually this.
23
+
24
+ **A model's `Date` fields are prototype accessors, not own properties.** `user.createdAt` is a `Dayjs` built
25
+ on first read, so `Object.keys(user)` and `{ ...user }` do **not** include it, while `"createdAt" in user`,
26
+ `JSON.stringify(user)` and `plainFieldsOf(user)` do. To copy a model write `new cnst.X().set(user)`, never a
27
+ spread.
28
+
29
+ ## Cascade — the value names the direction, and getting it wrong loses data
30
+
31
+ The two actions sit on the same field shape, so `cascade` never means "related". It means one of exactly
32
+ these:
33
+
34
+ - `removeRef` — *when I am removed, remove what this field points at.* Declared on the relation the owner
35
+ holds: `image: field(File, { cascade: "removeRef" })`.
36
+ - `removeWith` — *when what this field points at is removed, remove me.* Declared on the child's own
37
+ reference to its owner, so the owner never learns about its children.
38
+
39
+ Nothing checks whether another document still references the same target, and `File` in particular is
40
+ deduped by `origin`, so two parents can share one row. Removal is soft, but the storage delete a
41
+ `_postRemove` performs is not — a cascade is not restorable.
42
+
43
+ Query-level removes fire no hooks and therefore no cascade: `removeManyByQuery`, the generated
44
+ `remove<Filter>`, and the facade's `removeById`. Remove one document at a time when it cascades.
45
+
46
+ ## Field types
47
+
48
+ Import `Int`, `Float`, `ID`, `Any`, `Binary`, `Upload`, `enumOf` and `dayjs` from `akanjs/base`. `String`,
49
+ `Boolean` and `Date` are the globals. **`Number` is not a field type** — use `Int` or `Float`. There is no
50
+ JSON scalar; use `Any`. `Binary` is wire bytes and is never a model field.
51
+
52
+ Full detail: `get_guideline` with `scalarModule`, `scalarConstant`, `fieldRule`, or `queryRule`.
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: akan-service
3
+ description: "Add a service module — behaviour not centred on one stored model — under lib/_<service>/, and keep its abstract current."
4
+ ---
5
+
6
+ # Akan service modules
7
+
8
+ Behaviour that is not centred on a single stored model lives in a **service module**: the folder is
9
+ `lib/_<service>/` and its abstract file is `<service>.abstract.md` — the folder carries the underscore, the
10
+ abstract drops it. Its UI surface is limited to `<Service>.Util.tsx` and `<Service>.Zone.tsx`, and its
11
+ dictionary is a `serviceDictionary`.
12
+
13
+ ## Rules
14
+
15
+ - Read the module's `*.abstract.md` **before** changing it — it states the invariants the code cannot show.
16
+ Update it when an invariant, workflow, or public behaviour changes; not for formatting or imports.
17
+ - Keep the public surface in the signal layer and the decisions in the service.
18
+ - Service methods stay a few lines: load → chain → `return await ….save()`. Write `return await` explicitly
19
+ in tail position. Side effects belong in `_preUpdate` / `_postCreate`, not inline. Fire-and-forget is
20
+ explicitly `void`-ed.
21
+ - Return `null` / `false` for "not allowed" or "not found" and let the signal decide whether that is an
22
+ error.
23
+
24
+ ## Reaching other things
25
+
26
+ Inside a service, in preference order: `service<srv.XService>()` for another module's service,
27
+ `plug(AdapterClass)` for an adapter, `use<T>()` only for an `option.ts`-registered legacy singleton, and
28
+ `env(...)` for config. Injection resolves by field name — a field named `<refName>Service` finds the service
29
+ registered under `<refName>`, and the `Service` suffix is required.
30
+
31
+ An external API or piece of infrastructure is an `adapt()` class in `srvkit/`, injected with `plug`. It
32
+ self-registers, so do **not** add it to `lib/option.ts`.
33
+
34
+ Full detail: `get_guideline` with `modelService`.