@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
@@ -4,11 +4,13 @@ import {
4
4
  workflowPlanApproval,
5
5
  createWorkflowApplyReport,
6
6
  workflowCommandsForPlan,
7
+ workflowPathsForPlan,
7
8
  writeWorkflowRunArtifact,
8
9
  readWorkflowRunArtifact,
9
10
  createWorkflowBaselineSummary,
10
11
  createWorkflowValidationRunReport,
11
12
  createDryRunWorkflowApplyReport,
13
+ createWorkflowStepRegistry,
12
14
  WorkflowExecutor,
13
15
  listWorkflowSpecs,
14
16
  getWorkflowSpec,
@@ -20,18 +22,31 @@ import {
20
22
  renderWorkflowApply,
21
23
  renderWorkflowValidation,
22
24
  renderWorkflowRunArtifact
23
- } from "./index-gyd220p2.js";
25
+ } from "./index-yy4s1j72.js";
24
26
  import {
25
27
  AkanContextAnalyzer
26
- } from "./index-ktb5njgy.js";
28
+ } from "./index-9629w7ns.js";
27
29
  import {
30
+ CommandContainer,
28
31
  runner
29
- } from "./index-mak3cd28.js";
32
+ } from "./index-rmcw8yc8.js";
33
+ import {
34
+ ModuleScript
35
+ } from "./index-tgjy8xf3.js";
36
+ import {
37
+ PrimitiveScript
38
+ } from "./index-wp43xrjv.js";
39
+ import {
40
+ spawnShell
41
+ } from "./index-ya5qbmyg.js";
42
+ import {
43
+ ScalarScript
44
+ } from "./index-pp54p5zk.js";
30
45
 
31
46
  // pkgs/@akanjs/cli/workflow/workflow.runner.ts
32
47
  import { mkdir, readFile, writeFile } from "fs/promises";
33
48
  import path from "path";
34
- import { capitalize } from "akanjs/common";
49
+ import { isRecord } from "akanjs/common";
35
50
 
36
51
  // pkgs/@akanjs/cli/workflows/shared.ts
37
52
  var sysInputs = {
@@ -56,6 +71,12 @@ var baseValidation = [
56
71
  kind: "lint"
57
72
  }
58
73
  ];
74
+ var stepOf = (id, title, tool) => (description) => ({ id, title, tool, description });
75
+ var inspectModuleStep = stepOf("inspect-module", "Inspect module", "inspectModule");
76
+ var inspectSystemStep = stepOf("inspect-system", "Inspect target system", "inspectSystem");
77
+ var syncGeneratedStep = stepOf("sync-generated", "Sync generated files", "syncTarget");
78
+ var validateTargetStep = stepOf("validate-target", "Validate target", "lintTarget");
79
+ var validateTarget = validateTargetStep("Run validation commands for the target.");
59
80
 
60
81
  // pkgs/@akanjs/cli/workflows/addEnumField.ts
61
82
  var addEnumFieldWorkflowSpec = {
@@ -79,12 +100,7 @@ var addEnumFieldWorkflowSpec = {
79
100
  store: "infer"
80
101
  },
81
102
  steps: [
82
- {
83
- id: "inspect-module",
84
- title: "Inspect module",
85
- tool: "inspectModule",
86
- description: "Read module files and existing enum conventions."
87
- },
103
+ inspectModuleStep("Read module files and existing enum conventions."),
88
104
  {
89
105
  id: "update-constant",
90
106
  title: "Update enum field",
@@ -103,18 +119,8 @@ var addEnumFieldWorkflowSpec = {
103
119
  tool: "updateOptionEnum",
104
120
  description: "Plan option entries used by UI controls."
105
121
  },
106
- {
107
- id: "sync-generated",
108
- title: "Sync generated files",
109
- tool: "syncTarget",
110
- description: "Refresh generated files after enum source changes."
111
- },
112
- {
113
- id: "validate-target",
114
- title: "Validate target",
115
- tool: "lintTarget",
116
- description: "Run validation commands for the target."
117
- }
122
+ syncGeneratedStep("Refresh generated files after enum source changes."),
123
+ validateTarget
118
124
  ],
119
125
  predictedChanges: [
120
126
  { target: "*/lib/<module>/<module>.constant.ts", action: "modify", reason: "Enum field shape is added." },
@@ -146,7 +152,7 @@ var addFieldWorkflowSpec = {
146
152
  values: { type: "string-list", description: "Comma-separated enum values when type is enum." },
147
153
  default: {
148
154
  type: "string",
149
- description: "Optional default value. plan/apply coerce by field type: Int/Float to numeric literals, Boolean to true/false, Date to new Date(...), String/scalar to string literals, and enum only when the value is in values."
155
+ description: "Optional default value. plan/apply coerce by field type: Int/Float to numeric literals, Boolean to true/false, Date (now, a timestamp, or a date string) to a () => dayjs(...) thunk, String/scalar to string literals, and enum only when the value is in values."
150
156
  },
151
157
  surfaces: {
152
158
  type: "string-list",
@@ -165,12 +171,7 @@ var addFieldWorkflowSpec = {
165
171
  store: "infer"
166
172
  },
167
173
  steps: [
168
- {
169
- id: "inspect-module",
170
- title: "Inspect module",
171
- tool: "inspectModule",
172
- description: "Read module files and detect existing field/UI patterns."
173
- },
174
+ inspectModuleStep("Read module files and detect existing field/UI patterns."),
174
175
  {
175
176
  id: "update-constant",
176
177
  title: "Update constant",
@@ -190,18 +191,8 @@ var addFieldWorkflowSpec = {
190
191
  description: "Plan optional Template, Unit, View, and Store updates according to inferred surfaces.",
191
192
  when: "optionalSurfaces.* is include or infer"
192
193
  },
193
- {
194
- id: "sync-generated",
195
- title: "Sync generated files",
196
- tool: "syncTarget",
197
- description: "Refresh generated files after source changes."
198
- },
199
- {
200
- id: "validate-target",
201
- title: "Validate target",
202
- tool: "lintTarget",
203
- description: "Run validation commands for the target."
204
- }
194
+ syncGeneratedStep("Refresh generated files after source changes."),
195
+ validateTarget
205
196
  ],
206
197
  predictedChanges: [
207
198
  {
@@ -272,12 +263,7 @@ var addMutationWorkflowSpec = {
272
263
  dictionary: "include"
273
264
  },
274
265
  steps: [
275
- {
276
- id: "inspect-module",
277
- title: "Inspect module",
278
- tool: "inspectModule",
279
- description: "Read service, signal, store, and UI action patterns."
280
- },
266
+ inspectModuleStep("Read service, signal, store, and UI action patterns."),
281
267
  {
282
268
  id: "update-service",
283
269
  title: "Update service",
@@ -296,18 +282,8 @@ var addMutationWorkflowSpec = {
296
282
  tool: "updateActionSurfaces",
297
283
  description: "Plan optional store and UI action changes."
298
284
  },
299
- {
300
- id: "sync-generated",
301
- title: "Sync generated files",
302
- tool: "syncTarget",
303
- description: "Refresh generated service and signal barrels."
304
- },
305
- {
306
- id: "validate-target",
307
- title: "Validate target",
308
- tool: "lintTarget",
309
- description: "Run validation commands for the target."
310
- }
285
+ syncGeneratedStep("Refresh generated service and signal barrels."),
286
+ validateTarget
311
287
  ],
312
288
  predictedChanges: [
313
289
  {
@@ -355,12 +331,7 @@ var addSliceWorkflowSpec = {
355
331
  dictionary: "include"
356
332
  },
357
333
  steps: [
358
- {
359
- id: "inspect-module",
360
- title: "Inspect module",
361
- tool: "inspectModule",
362
- description: "Read existing query, slice, zone, and page loading patterns."
363
- },
334
+ inspectModuleStep("Read existing query, slice, zone, and page loading patterns."),
364
335
  {
365
336
  id: "update-service-query",
366
337
  title: "Update service query",
@@ -379,18 +350,8 @@ var addSliceWorkflowSpec = {
379
350
  tool: "connectSliceSurfaces",
380
351
  description: "Plan optional Zone and page loader changes."
381
352
  },
382
- {
383
- id: "sync-generated",
384
- title: "Sync generated files",
385
- tool: "syncTarget",
386
- description: "Refresh generated files after slice changes."
387
- },
388
- {
389
- id: "validate-target",
390
- title: "Validate target",
391
- tool: "lintTarget",
392
- description: "Run validation commands for the target."
393
- }
353
+ syncGeneratedStep("Refresh generated files after slice changes."),
354
+ validateTarget
394
355
  ],
395
356
  predictedChanges: [
396
357
  {
@@ -445,30 +406,15 @@ var createModuleWorkflowSpec = {
445
406
  view: "include"
446
407
  },
447
408
  steps: [
448
- {
449
- id: "inspect-system",
450
- title: "Inspect target system",
451
- tool: "inspectSystem",
452
- description: "Check the target app or library before planning new module files."
453
- },
409
+ inspectSystemStep("Check the target app or library before planning new module files."),
454
410
  {
455
411
  id: "create-module",
456
412
  title: "Create module",
457
413
  tool: "createModule",
458
414
  description: "Use the existing create-module primitive to scaffold conventional module files."
459
415
  },
460
- {
461
- id: "sync-generated",
462
- title: "Sync generated files",
463
- tool: "syncTarget",
464
- description: "Refresh generated barrels after adding a module."
465
- },
466
- {
467
- id: "validate-target",
468
- title: "Validate target",
469
- tool: "lintTarget",
470
- description: "Run validation commands that prove the scaffold matches Akan conventions."
471
- }
416
+ syncGeneratedStep("Refresh generated barrels after adding a module."),
417
+ validateTargetStep("Run validation commands that prove the scaffold matches Akan conventions.")
472
418
  ],
473
419
  predictedChanges: [
474
420
  { target: "*/lib/<module>/*", action: "create", reason: "New module source files are scaffolded." },
@@ -498,30 +444,15 @@ var createScalarWorkflowSpec = {
498
444
  dictionary: "include"
499
445
  },
500
446
  steps: [
501
- {
502
- id: "inspect-system",
503
- title: "Inspect target system",
504
- tool: "inspectSystem",
505
- description: "Check the target app or library before planning a scalar."
506
- },
447
+ inspectSystemStep("Check the target app or library before planning a scalar."),
507
448
  {
508
449
  id: "create-scalar",
509
450
  title: "Create scalar",
510
451
  tool: "createScalar",
511
452
  description: "Use the existing create-scalar primitive to scaffold scalar files."
512
453
  },
513
- {
514
- id: "sync-generated",
515
- title: "Sync generated files",
516
- tool: "syncTarget",
517
- description: "Refresh generated barrels after adding a scalar."
518
- },
519
- {
520
- id: "validate-target",
521
- title: "Validate target",
522
- tool: "lintTarget",
523
- description: "Run validation commands for the scalar target."
524
- }
454
+ syncGeneratedStep("Refresh generated barrels after adding a scalar."),
455
+ validateTargetStep("Run validation commands for the scalar target.")
525
456
  ],
526
457
  predictedChanges: [
527
458
  { target: "*/lib/__scalar/<scalar>/*", action: "create", reason: "New scalar source files are scaffolded." }
@@ -551,30 +482,15 @@ var createUiWorkflowSpec = {
551
482
  store: "infer"
552
483
  },
553
484
  steps: [
554
- {
555
- id: "inspect-module",
556
- title: "Inspect module",
557
- tool: "inspectModule",
558
- description: "Read existing module context and component files."
559
- },
485
+ inspectModuleStep("Read existing module context and component files."),
560
486
  {
561
487
  id: "create-ui",
562
488
  title: "Create UI surface",
563
489
  tool: "createUi",
564
490
  description: "Create the requested UI surface through an Akan primitive."
565
491
  },
566
- {
567
- id: "sync-generated",
568
- title: "Sync generated files",
569
- tool: "syncTarget",
570
- description: "Refresh UI barrels after adding a component."
571
- },
572
- {
573
- id: "validate-target",
574
- title: "Validate target",
575
- tool: "lintTarget",
576
- description: "Run validation commands for the target."
577
- }
492
+ syncGeneratedStep("Refresh UI barrels after adding a component."),
493
+ validateTarget
578
494
  ],
579
495
  predictedChanges: [
580
496
  { target: "*/lib/<module>/<Module>.<Surface>.tsx", action: "create", reason: "New UI component is created." },
@@ -597,7 +513,6 @@ var workflowSpecs = [
597
513
 
598
514
  // pkgs/@akanjs/cli/workflow/workflow.runner.ts
599
515
  var resolvePath = (filePath) => path.isAbsolute(filePath) ? filePath : path.join(process.cwd(), filePath);
600
- var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
601
516
  var isWorkflowPlan = (value) => {
602
517
  if (!isRecord(value))
603
518
  return false;
@@ -627,17 +542,19 @@ var failedPlan = (workflow, diagnostics) => ({
627
542
  requiresApproval: true,
628
543
  approval: workflowPlanApproval
629
544
  });
630
- var failedApplyReport = (workflow, diagnostics, plan) => createWorkflowApplyReport({
631
- workflow,
632
- mode: "apply",
633
- changedFiles: [],
634
- generatedFiles: [],
635
- commands: [],
636
- diagnostics,
637
- nextActions: [],
638
- plan: plan ?? failedPlan(workflow, diagnostics)
639
- });
640
- var commandForShell = (command) => command.startsWith("akan ") ? `bun run ${command}` : command;
545
+ var failedApplyReport = (workflow, code, message, plan) => {
546
+ const diagnostics = [{ severity: "error", code, message }];
547
+ return createWorkflowApplyReport({
548
+ workflow,
549
+ mode: "apply",
550
+ changedFiles: [],
551
+ generatedFiles: [],
552
+ commands: [],
553
+ diagnostics,
554
+ nextActions: [],
555
+ plan: plan ?? failedPlan(workflow, diagnostics)
556
+ });
557
+ };
641
558
  var inferValidationKind = (command) => {
642
559
  if (command.kind)
643
560
  return command.kind;
@@ -667,25 +584,13 @@ ${error.message ?? ""}`.toLowerCase();
667
584
  return "unknown";
668
585
  };
669
586
  var defaultValidationExecutor = (workspace) => async (command) => {
670
- const kind = inferValidationKind(command);
587
+ const base = { command: command.command, reason: command.reason, kind: inferValidationKind(command) };
671
588
  try {
672
- const stdout = await workspace.spawn("bash", ["-lc", commandForShell(command.command)], {
673
- cwd: workspace.workspaceRoot
674
- });
675
- return {
676
- command: command.command,
677
- reason: command.reason,
678
- kind,
679
- status: "passed",
680
- exitCode: 0,
681
- stdout
682
- };
589
+ return { ...base, status: "passed", exitCode: 0, stdout: await spawnShell(workspace, command.command) };
683
590
  } catch (error) {
684
591
  const commandError = error;
685
592
  return {
686
- command: command.command,
687
- reason: command.reason,
688
- kind,
593
+ ...base,
689
594
  status: "failed",
690
595
  exitCode: commandError.code ?? 1,
691
596
  failureScope: classifyValidationFailure(command, commandError),
@@ -695,24 +600,17 @@ var defaultValidationExecutor = (workspace) => async (command) => {
695
600
  }
696
601
  };
697
602
  var readJsonFile = async (filePath) => JSON.parse(await readFile(resolvePath(filePath), "utf8"));
698
- var planInputString = (plan, key) => {
699
- const value = plan.inputs[key];
700
- return typeof value === "string" ? value : "";
603
+ var workflowDiagnosticFromDoctor = ({
604
+ severity,
605
+ code,
606
+ message,
607
+ scope,
608
+ context
609
+ }, fallbackScope) => {
610
+ const resolvedScope = scope ?? fallbackScope;
611
+ const failureScope = resolvedScope === "baseline" ? "workspace-config" : resolvedScope === "workflow" ? "source-change" : "unknown";
612
+ return { severity, code, message, scope: resolvedScope, failureScope, context };
701
613
  };
702
- var workflowPathsForPlanLike = (plan) => {
703
- const app = planInputString(plan, "app");
704
- const module = planInputString(plan, "module");
705
- const moduleClass = module ? capitalize(module) : "<Module>";
706
- return plan.predictedChanges.map((change) => change.target.replace(/^\*\//, app ? `apps/${app}/` : "").replaceAll("<module>", module || "<module>").replaceAll("<Module>", moduleClass));
707
- };
708
- var workflowDiagnosticFromDoctor = (diagnostic, fallbackScope) => ({
709
- severity: diagnostic.severity,
710
- code: diagnostic.code,
711
- message: diagnostic.message,
712
- scope: diagnostic.scope ?? fallbackScope,
713
- failureScope: (diagnostic.scope ?? fallbackScope) === "baseline" ? "workspace-config" : (diagnostic.scope ?? fallbackScope) === "workflow" ? "source-change" : "unknown",
714
- context: diagnostic.context
715
- });
716
614
  var baselineBlockerCachePath = (workflow) => `.akan/workflows/baseline/${workflow}.json`;
717
615
  var blockerFingerprint = (blocker) => [blocker.failureScope, blocker.code, blocker.command ?? "", blocker.kind ?? "", blocker.message].join("|");
718
616
  var applyBaselineBlockerCache = async (workspace, report) => {
@@ -768,6 +666,18 @@ var withBaselineDetailsPolicy = (report, includeBaselineDetails) => {
768
666
  };
769
667
 
770
668
  class WorkflowRunner extends runner("workflow") {
669
+ static stepRegistry(workspace) {
670
+ return createWorkflowStepRegistry({
671
+ workspace,
672
+ createModule: (sys, module) => CommandContainer.get(ModuleScript).createModuleTemplate(sys, module),
673
+ createScalar: (sys, scalar) => CommandContainer.get(ScalarScript).createScalar(sys, scalar),
674
+ createUi: (input) => CommandContainer.get(PrimitiveScript).createUi(workspace, input),
675
+ addField: (input) => CommandContainer.get(PrimitiveScript).addField(workspace, input),
676
+ addEnumField: (input) => CommandContainer.get(PrimitiveScript).addEnumField(workspace, input),
677
+ addMutation: (input) => CommandContainer.get(PrimitiveScript).addMutation(workspace, input),
678
+ addSlice: (input) => CommandContainer.get(PrimitiveScript).addSlice(workspace, input)
679
+ });
680
+ }
771
681
  list({ format = "markdown" } = {}) {
772
682
  const workflows = listWorkflowSpecs(workflowSpecs);
773
683
  if (format === "json")
@@ -809,50 +719,24 @@ class WorkflowRunner extends runner("workflow") {
809
719
  };
810
720
  let plan;
811
721
  try {
812
- const parsed = JSON.parse(await readFile(resolvePath(planPath), "utf8"));
813
- if (!isWorkflowPlan(parsed)) {
814
- const report = failedApplyReport("unknown", [
815
- {
816
- severity: "error",
817
- code: "workflow-plan-invalid",
818
- message: `Workflow plan file is invalid: ${planPath}.`
819
- }
820
- ]);
821
- return await renderApplyReport(report);
822
- }
722
+ const parsed = await readJsonFile(planPath);
723
+ if (!isWorkflowPlan(parsed))
724
+ return await renderApplyReport(failedApplyReport("unknown", "workflow-plan-invalid", `Workflow plan file is invalid: ${planPath}.`));
823
725
  plan = parsed;
824
726
  } catch (error) {
825
- const report = failedApplyReport("unknown", [
826
- {
827
- severity: "error",
828
- code: "workflow-plan-read-failed",
829
- message: `Could not read workflow plan file: ${planPath}. ${error instanceof Error ? error.message : ""}`.trim()
830
- }
831
- ]);
832
- return await renderApplyReport(report);
727
+ const message = `Could not read workflow plan file: ${planPath}. ${error instanceof Error ? error.message : ""}`;
728
+ return await renderApplyReport(failedApplyReport("unknown", "workflow-plan-read-failed", message.trim()));
833
729
  }
834
730
  const spec = getWorkflowSpec(workflowSpecs, plan.workflow);
835
731
  if (!spec) {
836
- const report = failedApplyReport(plan.workflow, [
837
- {
838
- severity: "error",
839
- code: "workflow-unknown",
840
- message: `Unknown workflow in plan: ${plan.workflow}.`
841
- }
842
- ], plan);
843
- return await renderApplyReport(report);
732
+ const message = `Unknown workflow in plan: ${plan.workflow}.`;
733
+ return await renderApplyReport(failedApplyReport(plan.workflow, "workflow-unknown", message, plan));
844
734
  }
845
735
  if (dryRun)
846
736
  return await renderApplyReport(createDryRunWorkflowApplyReport(plan));
847
737
  if (!registry) {
848
- const report = failedApplyReport(plan.workflow, [
849
- {
850
- severity: "error",
851
- code: "workflow-registry-missing",
852
- message: "Workflow apply requires a step runner registry."
853
- }
854
- ], plan);
855
- return await renderApplyReport(report);
738
+ const message = "Workflow apply requires a step runner registry.";
739
+ return await renderApplyReport(failedApplyReport(plan.workflow, "workflow-registry-missing", message, plan));
856
740
  }
857
741
  return await renderApplyReport(await new WorkflowExecutor(registry, workspace).apply(plan));
858
742
  }
@@ -909,6 +793,15 @@ class WorkflowRunner extends runner("workflow") {
909
793
  }
910
794
  }
911
795
  async loadValidationTarget(runIdOrPlan, workspace) {
796
+ const unreadable = (code, message) => ({
797
+ workflow: "unknown",
798
+ source: { type: "run-report", runId: runIdOrPlan },
799
+ plan: undefined,
800
+ commands: [],
801
+ diagnostics: [{ severity: "error", code, message }],
802
+ changedFiles: [],
803
+ repairActions: []
804
+ });
912
805
  const loadFromArtifact = (artifact, sourcePath) => {
913
806
  if (isWorkflowApplyReport(artifact)) {
914
807
  return {
@@ -932,21 +825,7 @@ class WorkflowRunner extends runner("workflow") {
932
825
  repairActions: artifact.repairActions
933
826
  };
934
827
  }
935
- return {
936
- workflow: "unknown",
937
- source: { type: "run-report", runId: runIdOrPlan },
938
- plan: undefined,
939
- commands: [],
940
- diagnostics: [
941
- {
942
- severity: "error",
943
- code: "workflow-validation-source-unsupported",
944
- message: `Workflow validation source is not supported: ${runIdOrPlan}.`
945
- }
946
- ],
947
- changedFiles: [],
948
- repairActions: []
949
- };
828
+ return unreadable("workflow-validation-source-unsupported", `Workflow validation source is not supported: ${runIdOrPlan}.`);
950
829
  };
951
830
  try {
952
831
  const parsed = await readJsonFile(runIdOrPlan);
@@ -957,7 +836,7 @@ class WorkflowRunner extends runner("workflow") {
957
836
  plan: parsed,
958
837
  commands: workflowCommandsForPlan(parsed),
959
838
  diagnostics: parsed.diagnostics,
960
- changedFiles: workflowPathsForPlanLike(parsed),
839
+ changedFiles: workflowPathsForPlan(parsed),
961
840
  repairActions: []
962
841
  };
963
842
  }
@@ -968,21 +847,8 @@ class WorkflowRunner extends runner("workflow") {
968
847
  const artifact = await readWorkflowRunArtifact(workspace, runIdOrPlan);
969
848
  return loadFromArtifact(artifact, runIdOrPlan);
970
849
  } catch (error) {
971
- return {
972
- workflow: "unknown",
973
- source: { type: "run-report", runId: runIdOrPlan },
974
- plan: undefined,
975
- commands: [],
976
- diagnostics: [
977
- {
978
- severity: "error",
979
- code: "workflow-validation-source-read-failed",
980
- message: `Could not read workflow validation source: ${runIdOrPlan}. ${error instanceof Error ? error.message : ""}`.trim()
981
- }
982
- ],
983
- changedFiles: [],
984
- repairActions: []
985
- };
850
+ const message = `Could not read workflow validation source: ${runIdOrPlan}. ${error instanceof Error ? error.message : ""}`;
851
+ return unreadable("workflow-validation-source-read-failed", message.trim());
986
852
  }
987
853
  }
988
854
  }