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

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 (190) hide show
  1. package/.build-stamp +1 -1
  2. package/CodeAgent-q2m47rqp.js +9 -0
  3. package/CodeAgentRpcHost-p7h6n2hp.js +7 -0
  4. package/CodeAgentRpcListener-7p7z5dd7.js +97 -0
  5. package/CodeTui-pdqhc3sn.js +1457 -0
  6. package/README.md +3 -0
  7. package/TunnelShare-scf4e4pd.js +9 -0
  8. package/{agent.command-d2gfxfck.js → agent.command-ttn09rx3.js} +8 -9
  9. package/akanCode.js +102 -0
  10. package/application.command-7gweenv7.js +179 -0
  11. package/{applicationBuildRunner-kxwbssgn.js → applicationBuildRunner-38exmejd.js} +63 -64
  12. package/buildBatch.proc.js +26 -25
  13. package/cloud.command-bhztw7c2.js +95 -0
  14. package/cloud.script-aabyhgba.js +20 -0
  15. package/code.command-6s8c0k91.js +154 -0
  16. package/commandManifest.json +1 -1
  17. package/consoleToStderr-h5bryj94.js +7 -0
  18. package/context.command-phmgywt2.js +48 -0
  19. package/context.runner-yvyw5g2d.js +21 -0
  20. package/{dependencyScanner-shs82ynp.js → dependencyScanner-ye2e6pdz.js} +2 -2
  21. package/{devTui-40ggmd99.js → devTui-q7k7bakd.js} +122 -40
  22. package/fileSys-5ngz93ga.js +9 -0
  23. package/guideline.command-7jk47fgq.js +42 -0
  24. package/guidelines/agentRule/agentRule.instruction.md +209 -28
  25. package/guidelines/conventions/conventions.instruction.md +96 -29
  26. package/guidelines/fieldRule/fieldRule.instruction.md +1 -0
  27. package/guidelines/mcpRule/mcpRule.instruction.md +7 -5
  28. package/guidelines/queryRule/queryRule.instruction.md +17 -7
  29. package/guidelines/runtimeRule/runtimeRule.instruction.md +77 -3
  30. package/guidelines/ssrRule/ssrRule.instruction.md +4 -2
  31. package/guidelines/transportRule/transportRule.instruction.md +51 -0
  32. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +66 -3
  33. package/incrementalBuilder.proc.js +31 -48
  34. package/{index-h7yw2z9n.js → index-0bq14vr1.js} +8 -14
  35. package/{index-259dsnz3.js → index-1db2cw0y.js} +5 -8
  36. package/index-22d57v4c.js +266 -0
  37. package/index-3hx1z96c.js +87 -0
  38. package/{index-kcxmv48c.js → index-3t7g9e4r.js} +45 -79
  39. package/{index-ne2qy0nk.js → index-4dn1p115.js} +12 -12
  40. package/{index-q0y2jq9j.js → index-5b6tavv3.js} +6 -3
  41. package/index-7cqjvraf.js +69 -0
  42. package/index-7md2g9vw.js +6 -0
  43. package/{index-zry5nz81.js → index-8kb5p54p.js} +51 -30
  44. package/{index-ktb5njgy.js → index-9629w7ns.js} +49 -99
  45. package/index-9dp031by.js +12 -0
  46. package/{index-a64esmtb.js → index-aadpbnt2.js} +172 -308
  47. package/{index-3d9y066c.js → index-bjwxs904.js} +9 -8
  48. package/index-c6eggbee.js +123 -0
  49. package/index-d0arnrm8.js +700 -0
  50. package/index-d2242ksy.js +99 -0
  51. package/{index-600zhnve.js → index-dg97qp24.js} +70 -200
  52. package/{index-92zztqy1.js → index-dy0jx9ay.js} +2 -17
  53. package/{index-w8kmx1b6.js → index-fgq75haa.js} +198 -290
  54. package/{index-2tv3fdx4.js → index-ga6hygxr.js} +944 -1333
  55. package/{index-by5gpp8x.js → index-hj6w4ka1.js} +2 -1
  56. package/index-hr5n7t4x.js +465 -0
  57. package/{index-hwkygn9s.js → index-khpfpcsd.js} +302 -33
  58. package/{index-7737gxcp.js → index-m0ms3n1c.js} +107 -241
  59. package/{index-ws5e0j51.js → index-mgfx3mfs.js} +43 -26
  60. package/index-p6pbz9n5.js +25 -0
  61. package/index-pp54p5zk.js +53 -0
  62. package/{index-j9yhg404.js → index-q44jbw48.js} +4 -7
  63. package/{index-mak3cd28.js → index-rmcw8yc8.js} +137 -255
  64. package/{index-pnqbkf5p.js → index-rnt66vym.js} +6 -2
  65. package/index-smme4r47.js +49 -0
  66. package/index-tgjy8xf3.js +187 -0
  67. package/index-v5eayqqw.js +2729 -0
  68. package/index-wa5jbxj1.js +760 -0
  69. package/{index-4edzf1gr.js → index-wp43xrjv.js} +77 -150
  70. package/{index-fz5q3gd7.js → index-ya5qbmyg.js} +10 -17
  71. package/index-yjkte9aj.js +1119 -0
  72. package/{index-gyd220p2.js → index-yy4s1j72.js} +554 -577
  73. package/{index-v0qh106m.js → index-z50k041j.js} +580 -862
  74. package/index.js +23 -22
  75. package/{library.command-nbsky672.js → library.command-ccb1cp92.js} +4 -5
  76. package/{localRegistry.command-yeq57wjr.js → localRegistry.command-ajb9n87j.js} +23 -42
  77. package/{module.command-29vqzrh8.js → module.command-5k6h407d.js} +8 -11
  78. package/{package.command-axv0abmn.js → package.command-e6ntvpez.js} +6 -7
  79. package/package.json +14 -6
  80. package/{page.command-vs9s3zrh.js → page.command-v4f90wb8.js} +4 -5
  81. package/{primitive.command-cbxmqbtc.js → primitive.command-g6km57q5.js} +9 -22
  82. package/prompter-ptaa3nk0.js +8 -0
  83. package/{quality.command-gmbs7nws.js → quality.command-de3p36pz.js} +205 -377
  84. package/{recipeScanner-fpagtgc1.js → recipeScanner-4b69ybe0.js} +1 -1
  85. package/{repair.command-bqsjptsj.js → repair.command-d3x1javq.js} +11 -35
  86. package/{routeSourceValidator-apyqw7wk.js → routeSourceValidator-7ycnfz0e.js} +0 -6
  87. package/{scalar.command-6k1vhe9s.js → scalar.command-7ezrac2b.js} +7 -10
  88. package/skills/akan-code/SKILL.md +130 -0
  89. package/skills/akan-debug/SKILL.md +42 -0
  90. package/skills/akan-deps/SKILL.md +50 -0
  91. package/skills/akan-err/SKILL.md +39 -0
  92. package/skills/akan-module/SKILL.md +45 -0
  93. package/skills/akan-scaffold/SKILL.md +76 -0
  94. package/skills/akan-scalar/SKILL.md +52 -0
  95. package/skills/akan-service/SKILL.md +34 -0
  96. package/skills/akan-store/SKILL.md +67 -0
  97. package/skills/akan-ui/SKILL.md +63 -0
  98. package/skills/akan-validate/SKILL.md +44 -0
  99. package/{subspace.command-fwjfcts7.js → subspace.command-ps71ynp6.js} +138 -67
  100. package/templates/__scalar/__model__/__model__.abstract.md.template +8 -0
  101. package/templates/appSample/lib/__scalar/workHistory/workHistory.abstract.ts +8 -39
  102. package/templates/appSample/lib/_noti/noti.abstract.ts +6 -29
  103. package/templates/appSample/lib/task/task.abstract.ts +12 -32
  104. package/templates/appSample/lib/task/task.signal.spec.ts +15 -18
  105. package/templates/appSample/lib/task/task.signal.test.ts +15 -1
  106. package/templates/appSample/lib/task/task.signal.ts +1 -1
  107. package/templates/appSample/srvkit/{AuthGuard.ts → guards.ts} +7 -4
  108. package/templates/appSample/srvkit/{SessionInternalArg.ts → internalArgs.ts} +6 -4
  109. package/templates/client.ts +7 -30
  110. package/templates/crudPages/[__model__Id]/edit/page.tsx +2 -1
  111. package/templates/crudPages/[__model__Id]/page.tsx +2 -1
  112. package/templates/crudPages/new/page.tsx +2 -1
  113. package/templates/crudPages/page.tsx +2 -1
  114. package/templates/crudSinglePage/page.tsx +2 -1
  115. package/templates/lib/__lib/lib.dictionary.ts +0 -2
  116. package/templates/lib/__lib/lib.document.ts +0 -2
  117. package/templates/lib/sig.ts +8 -30
  118. package/templates/localDev/docker-compose.yaml.template +3 -14
  119. package/templates/module/__model__.signal.ts +12 -4
  120. package/templates/pkgRoot/tsconfig.json.template +2 -7
  121. package/templates/server.ts +0 -2
  122. package/templates/service/__model__.abstract.md.template +8 -0
  123. package/templates/workspaceRoot/.gitignore.template +0 -1
  124. package/tunnel.command-hsrv2mny.js +129 -0
  125. package/{typeChecker-3xgrzc2v.js → typeChecker-px49mezc.js} +1 -1
  126. package/typecheck.proc.js +1 -1
  127. package/workflow.command-z2p32nmf.js +79 -0
  128. package/{workspace.command-8s050m0h.js → workspace.command-tmdqkrh0.js} +77 -109
  129. package/abstractCompactor-mjh5ppsq.js +0 -101
  130. package/application.command-pj2m7584.js +0 -204
  131. package/applicationReleasePackager-4yasxwv9.js +0 -244
  132. package/capacitorApp-36rbr858.js +0 -12
  133. package/cloud.command-jshwdq22.js +0 -93
  134. package/context.command-ez8a0zyz.js +0 -80
  135. package/devTuiView-c08ccbat.js +0 -9
  136. package/getDirname-dr3jz1xg.js +0 -7
  137. package/guideline.command-xmqwx8zm.js +0 -359
  138. package/guidelines/agentRule/agentRule.generate.json +0 -31
  139. package/guidelines/componentRule/componentRule.generate.json +0 -31
  140. package/guidelines/conventions/conventions.generate.json +0 -25
  141. package/guidelines/cssRule/cssRule.generate.json +0 -31
  142. package/guidelines/docPageRule/docPageRule.generate.json +0 -31
  143. package/guidelines/docPageRule/docPageRule.instruction.md +0 -25
  144. package/guidelines/docSyncRule/docSyncRule.generate.json +0 -31
  145. package/guidelines/docSyncRule/docSyncRule.instruction.md +0 -25
  146. package/guidelines/enumConstant/enumConstant.generate.json +0 -31
  147. package/guidelines/enumConstant/enumConstant.instruction.md +0 -28
  148. package/guidelines/fieldRule/fieldRule.generate.json +0 -31
  149. package/guidelines/framework/framework.generate.json +0 -32
  150. package/guidelines/mcpRule/mcpRule.generate.json +0 -35
  151. package/guidelines/modelConstant/modelConstant.generate.json +0 -32
  152. package/guidelines/modelDictionary/modelDictionary.generate.json +0 -32
  153. package/guidelines/modelDocument/modelDocument.generate.json +0 -31
  154. package/guidelines/modelService/modelService.generate.json +0 -31
  155. package/guidelines/modelSignal/modelSignal.generate.json +0 -31
  156. package/guidelines/modelStore/modelStore.generate.json +0 -31
  157. package/guidelines/modelTemplate/modelTemplate.generate.json +0 -31
  158. package/guidelines/modelUnit/modelUnit.generate.json +0 -31
  159. package/guidelines/modelUtil/modelUtil.generate.json +0 -31
  160. package/guidelines/modelView/modelView.generate.json +0 -31
  161. package/guidelines/modelZone/modelZone.generate.json +0 -31
  162. package/guidelines/moduleCodegen/moduleCodegen.generate.json +0 -31
  163. package/guidelines/moduleCodegen/moduleCodegen.instruction.md +0 -28
  164. package/guidelines/moduleOverview/moduleOverview.generate.json +0 -31
  165. package/guidelines/queryRule/queryRule.generate.json +0 -31
  166. package/guidelines/recipeRule/recipeRule.generate.json +0 -31
  167. package/guidelines/runtimeRule/runtimeRule.generate.json +0 -25
  168. package/guidelines/scalarConstant/scalarConstant.generate.json +0 -32
  169. package/guidelines/scalarDictionary/scalarDictionary.generate.json +0 -32
  170. package/guidelines/scalarModule/scalarModule.generate.json +0 -31
  171. package/guidelines/sharedUiUsage/sharedUiUsage.generate.json +0 -31
  172. package/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +0 -25
  173. package/guidelines/ssrRule/ssrRule.generate.json +0 -31
  174. package/guidelines/transportRule/transportRule.generate.json +0 -31
  175. package/guidelines/utilUiUsage/utilUiUsage.generate.json +0 -31
  176. package/guidelines/utilUiUsage/utilUiUsage.instruction.md +0 -25
  177. package/guidelines/workspaceOnboarding/workspaceOnboarding.generate.json +0 -24
  178. package/guidelines/workspaceRecipes/workspaceRecipes.generate.json +0 -33
  179. package/index-2hq52jq3.js +0 -465
  180. package/index-47pj3aee.js +0 -76
  181. package/index-6wwzs1bc.js +0 -7
  182. package/index-8pm30m73.js +0 -841
  183. package/index-kn1h7p1x.js +0 -560
  184. package/index-meh558jy.js +0 -65
  185. package/index-rwg2aa4f.js +0 -229
  186. package/index-wt7qrtd4.js +0 -1516
  187. package/templates/__scalar/__model__/__model__.abstract.md +0 -28
  188. package/templates/module/__model__.abstract.md +0 -28
  189. package/templates/service/__model__.abstract.md +0 -28
  190. package/workflow.command-nwpcdc8p.js +0 -107
@@ -0,0 +1,129 @@
1
+ // @bun
2
+ import"./index-5b6tavv3.js";
3
+ import {
4
+ GlobalConfig,
5
+ CloudApi
6
+ } from "./index-22d57v4c.js";
7
+ import {
8
+ Workspace,
9
+ runner,
10
+ script,
11
+ command
12
+ } from "./index-rmcw8yc8.js";
13
+ import {
14
+ AppExecutor
15
+ } from "./index-ga6hygxr.js";
16
+ import {
17
+ TunnelShare2
18
+ } from "./index-smme4r47.js";
19
+ import {
20
+ writeClipboard
21
+ } from "./index-p6pbz9n5.js";
22
+
23
+ // pkgs/@akanjs/cli/tunnel/tunnel.script.ts
24
+ import { select } from "@inquirer/prompts";
25
+
26
+ // pkgs/@akanjs/cli/tunnel/tunnel.runner.ts
27
+ import { Logger } from "akanjs/common";
28
+ import chalk from "chalk";
29
+ class TunnelRunner extends runner("tunnel") {
30
+ async share(app, options) {
31
+ const spinner = app.spinning("Requesting a tunnel...");
32
+ const share = await TunnelShare2.open(app, {
33
+ ...options,
34
+ onLost: (reason) => Logger.rawLog(`tunnel disconnected (${reason}); reconnecting`, undefined, "error")
35
+ }).catch((error) => {
36
+ spinner.fail("Could not open the tunnel");
37
+ throw error;
38
+ });
39
+ spinner.succeed(`${app.name} is shared`);
40
+ const copied = await writeClipboard(share.url);
41
+ Logger.rawLog(`
42
+ ${chalk.bold(share.url)}${copied ? chalk.dim(" (copied)") : ""}`);
43
+ if (share.grant.expiresAt)
44
+ Logger.rawLog(chalk.dim(` expires ${share.grant.expiresAt}`));
45
+ Logger.rawLog(chalk.dim(` code ${share.grant.code} \u2014 stop it with: akan tunnel --stop ${share.grant.code}
46
+ `));
47
+ await TunnelRunner.holdUntilInterrupt(() => share.close());
48
+ }
49
+ async list(workspace, host = GlobalConfig.akanCloudHost) {
50
+ const api = await CloudApi.fromHost(workspace, host);
51
+ const tunnels = await api.tunnelListInSelf();
52
+ if (!tunnels.length) {
53
+ Logger.rawLog("No tunnels are open.");
54
+ return;
55
+ }
56
+ for (const tunnel of tunnels)
57
+ Logger.rawLog(`${tunnel.connected ? chalk.green("\u25CF") : chalk.dim("\u25CB")} ${tunnel.code} ${tunnel.url}` + `${tunnel.name ? ` ${chalk.dim(tunnel.name)}` : ""}` + `${tunnel.expiresAt ? chalk.dim(` expires ${tunnel.expiresAt}`) : ""}`);
58
+ }
59
+ async stop(code, workspace, host = GlobalConfig.akanCloudHost) {
60
+ const api = await CloudApi.fromHost(workspace, host);
61
+ const stopped = await api.revokeTunnel(code);
62
+ if (stopped)
63
+ Logger.rawLog(`Stopped ${code}.`);
64
+ else
65
+ Logger.rawLog(`No tunnel named ${code} is open.`, undefined, "error");
66
+ }
67
+ static holdUntilInterrupt(onInterrupt) {
68
+ return new Promise((resolve) => {
69
+ let closing = false;
70
+ const stop = () => {
71
+ if (closing) {
72
+ Logger.rawLog("Abandoning the tunnel release; it will expire on its own.", undefined, "error");
73
+ process.exit(130);
74
+ }
75
+ closing = true;
76
+ onInterrupt().then(() => resolve());
77
+ };
78
+ process.on("SIGINT", stop);
79
+ process.on("SIGTERM", stop);
80
+ });
81
+ }
82
+ }
83
+
84
+ // pkgs/@akanjs/cli/tunnel/tunnel.script.ts
85
+ class TunnelScript extends script("tunnel", [TunnelRunner]) {
86
+ static async resolveApp(workspace, name) {
87
+ const appNames = await workspace.getApps();
88
+ if (!appNames.length)
89
+ throw new Error("No apps found in this workspace (apps/<appName>/akan.config.ts)");
90
+ if (name && !appNames.includes(name))
91
+ throw new Error(`Unknown app: ${name}. Available: ${appNames.join(", ")}`);
92
+ if (name)
93
+ return AppExecutor.from(workspace, name);
94
+ const only = appNames.length === 1 ? appNames[0] : null;
95
+ if (only)
96
+ return AppExecutor.from(workspace, only);
97
+ return AppExecutor.from(workspace, await select({ message: "Select the app to share", choices: appNames }));
98
+ }
99
+ async share(name, { workspace, host, port, ttl }) {
100
+ const app = await TunnelScript.resolveApp(workspace, name);
101
+ await this.tunnelRunner.share(app, {
102
+ workspace,
103
+ ...host ? { host } : {},
104
+ ...port ? { port } : {},
105
+ ...ttl ? { ttlMinutes: ttl } : {}
106
+ });
107
+ }
108
+ async list(workspace, host) {
109
+ await this.tunnelRunner.list(workspace, host);
110
+ }
111
+ async stop(code, workspace, host) {
112
+ await this.tunnelRunner.stop(code, workspace, host);
113
+ }
114
+ }
115
+
116
+ // pkgs/@akanjs/cli/tunnel/tunnel.command.ts
117
+ class TunnelCommand extends command("tunnel", [TunnelScript], ({ public: target }) => ({
118
+ tunnel: target({ desc: "Share a locally running app on a public URL" }).arg("app", String, { desc: "app to share", nullable: true }).option("list", Boolean, { desc: "list the shares this account is holding", default: false }).option("stop", String, { desc: "stop the share with this code", default: "" }).option("host", String, { desc: "host of the cloud", default: GlobalConfig.akanCloudHost }).option("port", Number, { desc: "local port to share (default: the app's dev port)", nullable: true }).option("ttl", Number, { desc: "minutes before the share expires", nullable: true }).with(Workspace).exec(async function(app, list, stop, host, port, ttl, workspace) {
119
+ if (list)
120
+ return await this.tunnelScript.list(workspace, host);
121
+ if (stop)
122
+ return await this.tunnelScript.stop(stop, workspace, host);
123
+ await this.tunnelScript.share(app, { workspace, host, ...port ? { port } : {}, ...ttl ? { ttl } : {} });
124
+ })
125
+ })) {
126
+ }
127
+ export {
128
+ TunnelCommand
129
+ };
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  TypeChecker2
4
- } from "./index-92zztqy1.js";
4
+ } from "./index-dy0jx9ay.js";
5
5
  export {
6
6
  TypeChecker2 as TypeChecker
7
7
  };
package/typecheck.proc.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  TypeChecker2
4
- } from "./index-92zztqy1.js";
4
+ } from "./index-dy0jx9ay.js";
5
5
 
6
6
  // pkgs/@akanjs/devkit/typecheck/typecheck.proc.ts
7
7
  import { Logger } from "akanjs/common";
@@ -0,0 +1,79 @@
1
+ // @bun
2
+ import {
3
+ Workspace,
4
+ script,
5
+ command
6
+ } from "./index-rmcw8yc8.js";
7
+ import"./index-5b6tavv3.js";
8
+ import"./index-ga6hygxr.js";
9
+ import"./index-hj6w4ka1.js";
10
+ import"./index-yy4s1j72.js";
11
+ import"./index-9629w7ns.js";
12
+ import"./index-rnt66vym.js";
13
+ import"./index-tgjy8xf3.js";
14
+ import"./index-wp43xrjv.js";
15
+ import"./index-ya5qbmyg.js";
16
+ import"./index-pp54p5zk.js";
17
+ import {
18
+ WorkflowRunner
19
+ } from "./index-m0ms3n1c.js";
20
+
21
+ // pkgs/@akanjs/cli/workflow/workflow.script.ts
22
+ import { Logger } from "akanjs/common";
23
+ class WorkflowScript extends script("workflow", [WorkflowRunner]) {
24
+ async workflow(action, workflow, inputs, {
25
+ format = "markdown",
26
+ out = null,
27
+ dryRun = false,
28
+ workspace
29
+ } = {}) {
30
+ if (action === "list") {
31
+ Logger.rawLog(this.workflowRunner.list({ format }));
32
+ return;
33
+ }
34
+ if (!workflow)
35
+ throw new Error(`Workflow name is required for "${action}".`);
36
+ if (action === "explain") {
37
+ Logger.rawLog(this.workflowRunner.explain(workflow, { format }));
38
+ return;
39
+ }
40
+ if (action === "plan") {
41
+ Logger.rawLog(await this.workflowRunner.plan(workflow, inputs, { format, out }));
42
+ return;
43
+ }
44
+ if (action === "apply") {
45
+ if (!workspace)
46
+ throw new Error("Workspace is required for workflow apply.");
47
+ const registry = WorkflowRunner.stepRegistry(workspace);
48
+ Logger.rawLog(await this.workflowRunner.apply(workflow, { dryRun, format, workspace, registry }));
49
+ return;
50
+ }
51
+ if (action === "validate") {
52
+ if (!workspace)
53
+ throw new Error("Workspace is required for workflow validate.");
54
+ Logger.rawLog(await this.workflowRunner.validate(workflow, { format, workspace }));
55
+ return;
56
+ }
57
+ if (action === "report") {
58
+ if (!workspace)
59
+ throw new Error("Workspace is required for workflow report.");
60
+ Logger.rawLog(await this.workflowRunner.report(workflow, { format, workspace }));
61
+ return;
62
+ }
63
+ throw new Error(`Unknown workflow action: ${action}. Use list, explain, plan, apply, validate, or report.`);
64
+ }
65
+ }
66
+
67
+ // pkgs/@akanjs/cli/workflow/workflow.command.ts
68
+ class WorkflowCommand extends command("workflow", [WorkflowScript], ({ public: target }) => ({
69
+ workflow: target({ desc: "List, explain, plan, apply, validate, or report Akan workflows" }).arg("action", String, {
70
+ desc: "list, explain, plan, apply, validate, or report",
71
+ enum: ["list", "explain", "plan", "apply", "validate", "report"]
72
+ }).arg("workflow", String, { desc: "workflow name, plan path, or run id", nullable: true }).with(Workspace).option("format", String, { desc: "output format", flag: "o", default: "markdown", enum: ["markdown", "json"] }).option("out", String, { flag: "w", desc: "write workflow plan JSON to this path", nullable: true }).option("dryRun", Boolean, { flag: "r", desc: "show predicted apply report without writing files", default: false }).option("app", String, { desc: "target app or library name", nullable: true }).option("module", String, { desc: "target module name", nullable: true }).option("field", String, { desc: "field name", nullable: true }).option("type", String, { desc: "field type or scalar name", nullable: true }).option("values", String, { flag: "l", desc: "comma-separated values", nullable: true }).option("default", String, { desc: "default value", nullable: true }).option("scalar", String, { flag: "c", desc: "scalar name", nullable: true }).option("surface", String, { flag: "u", desc: "UI surface name", nullable: true }).option("mutation", String, { flag: "n", desc: "mutation name", nullable: true }).option("slice", String, { flag: "i", desc: "slice name", nullable: true }).exec(async function(action, workflow, workspace, format, out, dryRun, app, module, field, typeName, values, defaultValue, scalar, surface, mutation, slice) {
73
+ await this.workflowScript.workflow(action, workflow, { app, module, field, type: typeName, values, default: defaultValue, scalar, surface, mutation, slice }, { format, out, dryRun, workspace });
74
+ })
75
+ })) {
76
+ }
77
+ export {
78
+ WorkflowCommand
79
+ };
@@ -1,28 +1,28 @@
1
1
  // @bun
2
2
  import {
3
- FileSys
4
- } from "./index-q0y2jq9j.js";
3
+ FileSys2
4
+ } from "./index-5b6tavv3.js";
5
5
  import {
6
6
  GlobalConfig
7
- } from "./index-kn1h7p1x.js";
7
+ } from "./index-22d57v4c.js";
8
8
  import {
9
9
  Exec,
10
10
  Workspace,
11
11
  runner,
12
12
  script,
13
13
  command
14
- } from "./index-mak3cd28.js";
14
+ } from "./index-rmcw8yc8.js";
15
15
  import {
16
16
  extractAgentBlock,
17
17
  collectScopeRecipeSources,
18
18
  renderScopeAgentBlock,
19
+ Linter,
19
20
  WorkspaceExecutor,
20
21
  SysExecutor,
21
22
  AppExecutor,
22
23
  LibExecutor,
23
24
  PkgExecutor
24
- } from "./index-2tv3fdx4.js";
25
- import"./index-6wwzs1bc.js";
25
+ } from "./index-ga6hygxr.js";
26
26
  import {
27
27
  countBlocking,
28
28
  formatStyleContract,
@@ -31,42 +31,44 @@ import {
31
31
  import {
32
32
  collectRecipeSources2,
33
33
  scanRecipes2
34
- } from "./index-by5gpp8x.js";
35
- import"./index-gyd220p2.js";
36
- import"./index-ktb5njgy.js";
37
- import"./index-h7yw2z9n.js";
34
+ } from "./index-hj6w4ka1.js";
35
+ import"./index-yy4s1j72.js";
36
+ import"./index-9629w7ns.js";
37
+ import"./index-0bq14vr1.js";
38
38
  import {
39
39
  AgentScript
40
- } from "./index-ne2qy0nk.js";
41
- import {
42
- ApplicationScript
43
- } from "./index-v0qh106m.js";
40
+ } from "./index-4dn1p115.js";
41
+ import"./index-khpfpcsd.js";
44
42
  import {
45
43
  LibraryScript
46
- } from "./index-259dsnz3.js";
47
- import"./index-hwkygn9s.js";
48
- import"./index-kcxmv48c.js";
44
+ } from "./index-1db2cw0y.js";
45
+ import {
46
+ ApplicationScript
47
+ } from "./index-z50k041j.js";
48
+ import"./index-hr5n7t4x.js";
49
+ import"./index-7md2g9vw.js";
50
+ import"./index-3t7g9e4r.js";
49
51
  import {
50
52
  PackageScript
51
- } from "./index-ws5e0j51.js";
53
+ } from "./index-mgfx3mfs.js";
52
54
  import {
53
55
  getNpmRegistryUrl,
54
56
  getLatestPackageVersion
55
- } from "./index-2hq52jq3.js";
57
+ } from "./index-yjkte9aj.js";
56
58
  import {
57
- CloudScript
58
- } from "./index-zry5nz81.js";
59
+ CloudScript2
60
+ } from "./index-8kb5p54p.js";
61
+ import"./index-dg97qp24.js";
62
+ import"./index-ya5qbmyg.js";
63
+ import"./index-rnt66vym.js";
64
+ import"./index-tgjy8xf3.js";
65
+ import"./index-wp43xrjv.js";
66
+ import"./index-pp54p5zk.js";
67
+ import"./index-m0ms3n1c.js";
59
68
  import {
60
69
  ContextScript
61
- } from "./index-600zhnve.js";
62
- import"./index-wt7qrtd4.js";
63
- import"./index-fz5q3gd7.js";
64
- import"./index-7737gxcp.js";
65
- import"./index-8pm30m73.js";
66
- import"./index-pnqbkf5p.js";
67
- import"./index-4edzf1gr.js";
68
- import"./index-rwg2aa4f.js";
69
- import"./index-j9yhg404.js";
70
+ } from "./index-7cqjvraf.js";
71
+ import"./index-q44jbw48.js";
70
72
 
71
73
  // pkgs/@akanjs/cli/workspace/workspace.runner.ts
72
74
  import path from "path";
@@ -95,29 +97,15 @@ var defaultMaxDiagnostics = 200;
95
97
  class WorkspaceRunner extends runner("workspace") {
96
98
  async generateAgentRules(workspace, { overwrite = false, cursorRules = true } = {}) {
97
99
  const [appNames] = await workspace.getExecs();
98
- const dict = {
99
- repoName: workspace.repoName,
100
- appName: appNames[0] ?? "app"
101
- };
102
- const created = await workspace.applyTemplate({
103
- basePath: ".",
104
- template: "workspaceRoot/AGENTS.md.template",
105
- dict,
106
- overwrite
107
- });
108
- created.push(...await workspace.applyTemplate({
109
- basePath: ".",
110
- template: "workspaceRoot/CLAUDE.md.template",
111
- dict,
112
- overwrite
113
- }));
114
- if (cursorRules)
115
- created.push(...await workspace.applyTemplate({
116
- basePath: ".cursor/rules",
117
- template: "workspaceRoot/.cursor/rules/akan.mdc.template",
118
- dict,
119
- overwrite
120
- }));
100
+ const dict = { repoName: workspace.repoName, appName: appNames[0] ?? "app" };
101
+ const templates = [
102
+ [".", "workspaceRoot/AGENTS.md.template"],
103
+ [".", "workspaceRoot/CLAUDE.md.template"],
104
+ ...cursorRules ? [[".cursor/rules", "workspaceRoot/.cursor/rules/akan.mdc.template"]] : []
105
+ ];
106
+ const created = [];
107
+ for (const [basePath, template] of templates)
108
+ created.push(...await workspace.applyTemplate({ basePath, template, dict, overwrite }));
121
109
  return created;
122
110
  }
123
111
  async createWorkspace(repoName, appName, {
@@ -180,57 +168,47 @@ class WorkspaceRunner extends runner("workspace") {
180
168
  return Object.fromEntries(Object.entries(dependencyVersions).filter(([dependency]) => defaultWorkspacePeerDependencies.has(dependency)));
181
169
  }
182
170
  async#getCliPackageJson() {
183
- const packageJsonCandidates = [
171
+ const found = await this.#findPackageJson("@akanjs/cli", [
184
172
  path.join(import.meta.dir, "../package.json"),
185
173
  path.join(import.meta.dir, "package.json"),
186
174
  path.join(path.dirname(Bun.main), "package.json")
187
- ];
188
- try {
189
- packageJsonCandidates.unshift(Bun.resolveSync("@akanjs/cli/package.json", import.meta.dir));
190
- } catch {}
191
- for (const packageJsonPath of packageJsonCandidates) {
192
- if (!await Bun.file(packageJsonPath).exists())
193
- continue;
194
- const packageJson = await FileSys.readJson(packageJsonPath);
195
- if (packageJson.name === "@akanjs/cli")
196
- return packageJson;
197
- }
198
- return { name: "@akanjs/cli", version: "0.0.0", description: "@akanjs/cli" };
175
+ ]);
176
+ return found ?? { name: "@akanjs/cli", version: "0.0.0", description: "@akanjs/cli" };
199
177
  }
200
178
  async#getAkanPackageJson() {
201
- const packageJsonCandidates = [
179
+ const ancestors = [];
180
+ for (let current = import.meta.dir, depth = 0;depth < 6; depth++) {
181
+ ancestors.push(path.join(current, "package.json"));
182
+ if (path.dirname(current) === current)
183
+ break;
184
+ current = path.dirname(current);
185
+ }
186
+ const found = await this.#findPackageJson("akanjs", [
202
187
  path.join(import.meta.dir, "../../../akanjs/package.json"),
203
188
  path.join(process.cwd(), "pkgs/akanjs/package.json"),
204
- path.join(path.dirname(Bun.main), "node_modules/akanjs/package.json")
205
- ];
189
+ path.join(path.dirname(Bun.main), "node_modules/akanjs/package.json"),
190
+ ...ancestors
191
+ ]);
192
+ if (!found)
193
+ throw new Error(`[workspace] failed to locate akanjs package.json from ${import.meta.dir}`);
194
+ return found;
195
+ }
196
+ async#findPackageJson(name, candidates) {
206
197
  try {
207
- packageJsonCandidates.unshift(Bun.resolveSync("akanjs/package.json", import.meta.dir));
198
+ candidates.unshift(Bun.resolveSync(`${name}/package.json`, import.meta.dir));
208
199
  } catch {}
209
- for (const packageJsonPath of packageJsonCandidates) {
200
+ for (const packageJsonPath of candidates) {
210
201
  if (!await Bun.file(packageJsonPath).exists())
211
202
  continue;
212
- const packageJson = await FileSys.readJson(packageJsonPath);
213
- if (packageJson.name === "akanjs")
203
+ const packageJson = await FileSys2.readJson(packageJsonPath);
204
+ if (packageJson.name === name)
214
205
  return packageJson;
215
206
  }
216
- let current = import.meta.dir;
217
- for (let depth = 0;depth < 6; depth++) {
218
- const packageJsonPath = path.join(current, "package.json");
219
- if (await Bun.file(packageJsonPath).exists()) {
220
- const packageJson = await FileSys.readJson(packageJsonPath);
221
- if (packageJson.name === "akanjs")
222
- return packageJson;
223
- }
224
- const parent = path.dirname(current);
225
- if (parent === current)
226
- break;
227
- current = parent;
228
- }
229
- throw new Error(`[workspace] failed to locate akanjs package.json from ${import.meta.dir}`);
207
+ return null;
230
208
  }
231
209
  async lint(exec, workspace, { fix = true, maxDiagnostics = defaultMaxDiagnostics } = {}) {
232
210
  const configPath = await WorkspaceRunner.resolveBiomeConfigPath(workspace);
233
- await workspace.spawn("./node_modules/.bin/biome", [
211
+ await workspace.spawn(`./node_modules/.bin/${Linter.biomeBinName}`, [
234
212
  "check",
235
213
  ...fix ? ["--write"] : [],
236
214
  "--no-errors-on-unmatched",
@@ -327,7 +305,7 @@ class WorkspaceScript extends script("workspace", [
327
305
  ApplicationScript,
328
306
  LibraryScript,
329
307
  PackageScript,
330
- CloudScript,
308
+ CloudScript2,
331
309
  ContextScript,
332
310
  AgentScript
333
311
  ]) {
@@ -438,10 +416,13 @@ class WorkspaceScript extends script("workspace", [
438
416
  }
439
417
 
440
418
  // pkgs/@akanjs/cli/workspace/workspace.command.ts
419
+ var maxDiagnosticsOption = {
420
+ desc: "How many diagnostics Biome prints before truncating (0 for no limit)",
421
+ default: defaultMaxDiagnostics
422
+ };
423
+
441
424
  class WorkspaceCommand extends command("workspace", [WorkspaceScript], ({ public: target }) => ({
442
- createWorkspace: target({ desc: "Create a new Akan.js workspace", runsOnWorkspaceRoot: false }).arg("workspaceName", String, { desc: "what is the name of your organization?" }).option("app", String, {
443
- desc: "what is the codename of your first application? (e.g. myapp)"
444
- }).option("dir", String, {
425
+ createWorkspace: target({ desc: "Create a new Akan.js workspace", runsOnWorkspaceRoot: false }).arg("workspaceName", String, { desc: "what is the name of your organization?" }).option("app", String, { desc: "what is the codename of your first application? (e.g. myapp)" }).option("dir", String, {
445
426
  desc: "directory of workspace",
446
427
  default: process.env.USE_AKANJS_PKGS === "true" ? "local" : "."
447
428
  }).option("libs", Boolean, {
@@ -454,17 +435,10 @@ class WorkspaceCommand extends command("workspace", [WorkspaceScript], ({ public
454
435
  }
455
436
  ],
456
437
  default: false
457
- }).option("init", Boolean, {
458
- desc: "Do you want to initialize the workspace? (Recommended)",
459
- default: true
460
- }).option("registry", String, {
438
+ }).option("init", Boolean, { desc: "Do you want to initialize the workspace? (Recommended)", default: true }).option("registry", String, {
461
439
  desc: "npm registry URL for installing Akan packages",
462
440
  default: process.env.AKAN_NPM_REGISTRY ?? "https://registry.npmjs.org"
463
- }).option("owner", String, {
464
- desc: "owner of the workspace",
465
- default: process.env.GITHUB_OWNER,
466
- nullable: true
467
- }).option("mcpInstall", Boolean, {
441
+ }).option("owner", String, { desc: "owner of the workspace", default: process.env.GITHUB_OWNER, nullable: true }).option("mcpInstall", Boolean, {
468
442
  desc: "Install the Akan MCP server config for Cursor, Claude Code, and Codex? (Recommended)",
469
443
  default: true
470
444
  }).option("agentInstall", Boolean, {
@@ -488,16 +462,10 @@ class WorkspaceCommand extends command("workspace", [WorkspaceScript], ({ public
488
462
  }).option("overwrite", Boolean, { desc: "Overwrite existing agent rule files", default: false }).option("cursorRules", Boolean, { desc: "Generate .cursor/rules/akan.mdc", default: true }).with(Workspace).exec(async function(overwrite, cursorRules, workspace) {
489
463
  await this.workspaceScript.generateAgentRules(workspace, { overwrite, cursorRules });
490
464
  }),
491
- lint: target({ desc: "Lint and fix code in a specific app/lib/pkg" }).with(Exec).option("fix", Boolean, { default: true }).option("maxDiagnostics", Number, {
492
- desc: "How many diagnostics Biome prints before truncating (0 for no limit)",
493
- default: defaultMaxDiagnostics
494
- }).with(Workspace).exec(async function(exec, fix, maxDiagnostics, workspace) {
465
+ lint: target({ desc: "Lint and fix code in a specific app/lib/pkg" }).with(Exec).option("fix", Boolean, { default: true }).option("maxDiagnostics", Number, maxDiagnosticsOption).with(Workspace).exec(async function(exec, fix, maxDiagnostics, workspace) {
495
466
  await this.workspaceScript.lint(exec, workspace, { fix, maxDiagnostics });
496
467
  }),
497
- lintAll: target({ desc: "Lint and fix code in all apps and libraries" }).option("fix", Boolean, { default: true }).option("maxDiagnostics", Number, {
498
- desc: "How many diagnostics Biome prints before truncating (0 for no limit)",
499
- default: defaultMaxDiagnostics
500
- }).with(Workspace).exec(async function(fix, maxDiagnostics, workspace) {
468
+ lintAll: target({ desc: "Lint and fix code in all apps and libraries" }).option("fix", Boolean, { default: true }).option("maxDiagnostics", Number, maxDiagnosticsOption).with(Workspace).exec(async function(fix, maxDiagnostics, workspace) {
501
469
  await this.workspaceScript.lintAll(workspace, { fix, maxDiagnostics });
502
470
  }),
503
471
  syncAll: target({ desc: "Sync dependencies and configuration for all apps and libraries" }).with(Workspace).exec(async function(workspace) {
@@ -1,101 +0,0 @@
1
- // @bun
2
- import"./index-q0y2jq9j.js";
3
- import {
4
- AiSession
5
- } from "./index-kn1h7p1x.js";
6
- import {
7
- AbstractDoc
8
- } from "./index-meh558jy.js";
9
-
10
- // pkgs/@akanjs/devkit/abstractCompactor.ts
11
- import { Logger } from "akanjs/common";
12
- import chalk from "chalk";
13
- class AbstractCompactor {
14
- static #reviewRequest = `Review the compacted file you just wrote against the original.
15
- - Did you drop an invariant, a security reason, or a workflow step that the source files cannot show by themselves? Restore it.
16
- - Did you keep anything that only restates code, scaffold wording, or history? Remove it.
17
- - Is it in the same language as the original, within the line budget, and one short line per bullet?
18
- Respond with exactly one \`\`\`markdown code block holding the corrected file and nothing else. If nothing needs to change, repeat the file unchanged.`;
19
- #sys;
20
- #minLines;
21
- #interactive;
22
- constructor(sys, { minLines = AbstractDoc.compactMinLines, interactive = false } = {}) {
23
- this.#sys = sys;
24
- this.#minLines = minLines;
25
- this.#interactive = interactive;
26
- }
27
- async compactAll({ module } = {}) {
28
- const docs = await AbstractDoc.findAll(this.#sys, { module });
29
- const targets = docs.filter((doc) => doc.lineCount > this.#minLines);
30
- const reports = [];
31
- for (const doc of targets)
32
- reports.push(await this.compact(doc));
33
- return { scanned: docs.length, reports };
34
- }
35
- async compact(doc) {
36
- const session = new AiSession("compactAbstract", {
37
- workspace: this.#sys.workspace,
38
- cacheKey: `${this.#sys.name}-${doc.moduleName}`
39
- });
40
- const approve = !this.#interactive;
41
- const compacted = await session.editMarkdown(this.#request(doc), { approve });
42
- const reviewed = await session.editMarkdown(AbstractCompactor.#reviewRequest, { approve });
43
- const next = [reviewed, compacted].map((candidate) => candidate.trim()).find((candidate) => doc.canReplaceWith(candidate));
44
- const beforeLines = doc.lineCount;
45
- if (!next) {
46
- Logger.rawLog(chalk.yellow(`${doc.path}: the editor returned no shorter abstract, keeping the current file`));
47
- return { path: doc.path, beforeLines, afterLines: beforeLines, status: "failed" };
48
- }
49
- if (next === doc.content.trim())
50
- return { path: doc.path, beforeLines, afterLines: beforeLines, status: "unchanged" };
51
- const content = `${next}
52
- `;
53
- await this.#sys.writeFile(doc.path, content);
54
- return { path: doc.path, beforeLines, afterLines: AbstractDoc.lineCountOf(content), status: "compacted" };
55
- }
56
- #targetShape(kind) {
57
- if (kind === "other")
58
- return " - keep the headings that still carry information and drop the rest; do not impose a new structure";
59
- return [
60
- " - `# <name> Abstract` title line",
61
- " - one declarative sentence naming what this module owns",
62
- " - `## Rules` \u2014 two to five bullets, each an invariant the code cannot show by itself",
63
- " - optional `## Workflow` \u2014 the lifecycle as an arrow chain (`draft -> signed -> active`) or a few bullets"
64
- ].join(`
65
- `);
66
- }
67
- #request(doc) {
68
- return `You are compacting an Akan.js abstract file.
69
-
70
- An abstract is the summary a coding agent reads before changing a module. Repeated edits have made this one
71
- bloated, and it has to shrink back to what the source files cannot show by themselves.
72
-
73
- # Target file
74
- ${this.#sys.type}s/${this.#sys.name}/${doc.path} (${doc.kind} module "${doc.moduleName}", ${doc.lineCount} lines)
75
-
76
- # Source files in the same folder
77
- ${doc.siblingFiles.join(", ") || "none"}
78
-
79
- # Current content
80
- \`\`\`markdown
81
- ${doc.content}
82
- \`\`\`
83
-
84
- # Rules for the compacted file
85
- - Write it in the SAME language as the current content. Never translate.
86
- - Keep every invariant, constraint, security reason, and workflow step that the source files cannot show by
87
- themselves. Merge duplicates instead of dropping either one.
88
- - Delete what the code already states: field lists, types, labels, signatures, file lists, and imports.
89
- - Delete scaffold and placeholder wording, changelog or migration history, TODOs, and any instruction about
90
- reading or updating this file.
91
- - Never invent a rule that the current content does not state.
92
- - Keep every bullet to one short line, and stay under ${AbstractDoc.compactMinLines} lines in total.
93
- - Shape:
94
- ${this.#targetShape(doc.kind)}
95
-
96
- Respond with exactly one \`\`\`markdown code block holding the whole new file and nothing else.`;
97
- }
98
- }
99
- export {
100
- AbstractCompactor
101
- };