@akanjs/cli 3.2.0-rc.1 → 3.2.0-rc.11

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 (99) hide show
  1. package/.build-stamp +2 -1
  2. package/{CodeAgent-vmd9k4ak.js → CodeAgent-fk66n37w.js} +3 -3
  3. package/{CodeTui-zka44v52.js → CodeTui-4rf1mqmv.js} +1 -1
  4. package/README.ko.md +26 -1
  5. package/README.md +26 -1
  6. package/TunnelShare-44er4e29.js +15 -0
  7. package/{agent.command-2f657613.js → agent.command-7g9czkkd.js} +20 -19
  8. package/akanCode.js +3 -3
  9. package/{application.command-q6skd3am.js → application.command-00spg55s.js} +31 -24
  10. package/{applicationBuildRunner-sctcmkyx.js → applicationBuildRunner-f4yf0qyc.js} +9 -7
  11. package/buildBatch.proc.js +7 -6
  12. package/{cloud.command-7642pks6.js → cloud.command-ab704p0g.js} +24 -25
  13. package/cloud.script-4p4y0s7e.js +31 -0
  14. package/{code.command-7s4ndq2k.js → code.command-m6c9xk56.js} +7 -6
  15. package/{context.command-569z0rqf.js → context.command-hgcgxtdk.js} +20 -19
  16. package/context.runner-w071gmc3.js +30 -0
  17. package/{devTui-w38ch13a.js → devTui-h77zrjv5.js} +1 -1
  18. package/{guideline.command-gnv3e8p8.js → guideline.command-6yz6d4hf.js} +3 -2
  19. package/guidelines/agentRule/agentRule.instruction.md +4 -3
  20. package/guidelines/akanApi/akanApi.instruction.md +2 -0
  21. package/guidelines/conventions/core.md +1 -1
  22. package/guidelines/conventions/rules/app.md +3 -0
  23. package/guidelines/conventions/rules/page.md +5 -0
  24. package/guidelines/errorCodes/errorCodes.instruction.md +140 -0
  25. package/guidelines/fieldRule/fieldRule.instruction.md +2 -1
  26. package/guidelines/mcpRule/mcpRule.instruction.md +72 -2
  27. package/guidelines/pageRule/pageRule.instruction.md +5 -0
  28. package/guidelines/runtimeRule/runtimeRule.instruction.md +5 -1
  29. package/guidelines/transportRule/transportRule.instruction.md +5 -0
  30. package/incrementalBuilder.proc.js +8 -7
  31. package/{index-vkzfk7qt.js → index-097bjwvm.js} +40 -30
  32. package/{index-93ewzmp6.js → index-23d8gw08.js} +165 -102
  33. package/{index-p6hjwt2d.js → index-41mfhgq0.js} +72 -26
  34. package/{index-ktb3wcqz.js → index-4k9nv4m3.js} +71 -81
  35. package/{index-vr68mxj5.js → index-5jwx4bf2.js} +69 -33
  36. package/{index-5w9my9qe.js → index-6eptmk8z.js} +30 -20
  37. package/{index-d4n1wmrz.js → index-6fnrhpn1.js} +8 -4
  38. package/{index-kpdv34rq.js → index-6qtxs86x.js} +10 -7
  39. package/{index-ed6ea0qp.js → index-6z57w95f.js} +1 -1
  40. package/{index-drz9e84d.js → index-7ky4brfy.js} +2 -2
  41. package/{index-8g7tdsk4.js → index-849qvd7t.js} +58 -29
  42. package/{index-1q1cjn8s.js → index-9xh4zvw3.js} +94 -53
  43. package/{index-48d5qsj3.js → index-adj7qmz9.js} +23 -15
  44. package/{index-fjr4d6yd.js → index-apcr1qgk.js} +458 -304
  45. package/{index-8ts9774g.js → index-aybfcx58.js} +9 -4
  46. package/{index-8kczhnmv.js → index-b3pr4ee6.js} +1 -1
  47. package/{index-23860fej.js → index-b4qq3rq0.js} +23 -8
  48. package/{index-thckcabc.js → index-bper31wr.js} +24 -6
  49. package/{index-a8a9ede9.js → index-bxkx0x03.js} +14 -7
  50. package/{index-0fb3cpbt.js → index-c3r23w24.js} +9 -7
  51. package/{index-8pb9yvp8.js → index-dfsa009c.js} +148 -31
  52. package/{index-zpv14wpy.js → index-dsg50er9.js} +3 -3
  53. package/{index-hqrkqxx2.js → index-e5f6czck.js} +46 -7
  54. package/{index-sy481q2x.js → index-frvjq1rd.js} +1 -1
  55. package/{index-abgh0jve.js → index-grt0e6kk.js} +1 -1
  56. package/{index-e3vmjtph.js → index-hf9nvwam.js} +7 -2
  57. package/{index-v4p1zye8.js → index-hhagjhkh.js} +7 -7
  58. package/index-j4yvgfhr.js +70 -0
  59. package/{index-s2grpzef.js → index-k2r3hmbz.js} +6 -4
  60. package/{index-7y5yghjg.js → index-nd39rssn.js} +1162 -435
  61. package/{index-6wpaq392.js → index-p4htjyvk.js} +44 -5
  62. package/{index-aj3ehkcx.js → index-p54s83sz.js} +1 -1
  63. package/{index-7xdpww43.js → index-rdx8cyv2.js} +342 -134
  64. package/{index-sr5da35e.js → index-sq9d0jhj.js} +21 -18
  65. package/{index-eajbmk10.js → index-t4d0ckde.js} +2 -2
  66. package/{index-mqntfzv5.js → index-t8h09yjs.js} +7 -2
  67. package/index-va90m8nd.js +25 -0
  68. package/{index-rc5fvqj2.js → index-xfv2p7b5.js} +95 -58
  69. package/{index-w639tvkd.js → index-xgqz3kak.js} +29 -8
  70. package/{index-9tbgb4d8.js → index-xy70tcv4.js} +1 -1
  71. package/{index-mmym5xmb.js → index-z43wddce.js} +5 -3
  72. package/index.js +24 -23
  73. package/{library.command-1gp5qe3r.js → library.command-kc1zahcg.js} +5 -4
  74. package/{localRegistry.command-x7jptkd3.js → localRegistry.command-bz2df40m.js} +19 -18
  75. package/{module.command-4xz9he6h.js → module.command-cchwzz9r.js} +12 -7
  76. package/{package.command-s7qpnn1g.js → package.command-qcjajpv8.js} +8 -7
  77. package/package.json +2 -2
  78. package/{page.command-fan34c49.js → page.command-1t86dx8a.js} +4 -3
  79. package/{pipeline.command-ph4fnn9w.js → pipeline.command-2xx9z3d0.js} +3 -2
  80. package/{primitive.command-3fqh8emf.js → primitive.command-mc0x8txr.js} +8 -7
  81. package/{projectTypecheck-vkb40hjc.js → projectTypecheck-tz497yx7.js} +2 -1
  82. package/{quality.command-ecj6exsh.js → quality.command-11rayf5c.js} +7 -6
  83. package/{repair.command-fe9jw719.js → repair.command-8w41vy78.js} +7 -6
  84. package/{scalar.command-cnvfhk0n.js → scalar.command-rvwh98ny.js} +7 -6
  85. package/skills/akan-debug/SKILL.md +7 -3
  86. package/skills/akan-err/SKILL.md +7 -0
  87. package/skills/akan-mcp/SKILL.md +10 -1
  88. package/skills/akan-scaffold/SKILL.md +3 -2
  89. package/skills/akan-transport/SKILL.md +2 -0
  90. package/skills/akan-validate/SKILL.md +1 -0
  91. package/{subspace.command-qw5ddd6y.js → subspace.command-0970n7kd.js} +9 -8
  92. package/{tunnel.command-ggj38mqf.js → tunnel.command-bcy0rtmh.js} +8 -7
  93. package/typecheck.proc.js +5 -2
  94. package/{verify.command-w9ttxkdz.js → verify.command-ynaztxr2.js} +18 -16
  95. package/{workflow.command-ss8devj0.js → workflow.command-yp9ajthb.js} +45 -16
  96. package/{workspace.command-6z2rh8ze.js → workspace.command-e4wfxm86.js} +39 -34
  97. package/TunnelShare-k3ja4w9x.js +0 -14
  98. package/cloud.script-1sfseznn.js +0 -30
  99. package/context.runner-ms8v1rxy.js +0 -29
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-93ewzmp6.js";
5
+ } from "./index-23d8gw08.js";
6
6
  import {
7
7
  ModuleExecutor
8
- } from "./index-sr5da35e.js";
8
+ } from "./index-sq9d0jhj.js";
9
9
  import {
10
10
  sourceFile,
11
11
  moduleSourcePaths,
@@ -13,13 +13,16 @@ import {
13
13
  createPassedPrimitiveReport,
14
14
  bilingualLabelForField,
15
15
  bilingualDescriptionForField
16
- } from "./index-8pb9yvp8.js";
16
+ } from "./index-dfsa009c.js";
17
17
  import {
18
18
  PageScript
19
- } from "./index-aj3ehkcx.js";
19
+ } from "./index-p54s83sz.js";
20
20
  import {
21
21
  pluralizeName
22
22
  } from "./index-nz8prx9g.js";
23
+ import {
24
+ assertPlainName
25
+ } from "./index-va90m8nd.js";
23
26
 
24
27
  // pkgs/@akanjs/cli/module/module.script.ts
25
28
  import { capitalize as capitalize2 } from "akanjs/common";
@@ -137,6 +140,7 @@ var moduleChangedFiles = (sys, moduleName, files) => Object.values(files).map((f
137
140
 
138
141
  class ModuleScript extends script("module", [ModuleRunner, PageScript]) {
139
142
  async createModuleTemplate(sys, name, { page = false } = {}) {
143
+ assertPlainName("module", name);
140
144
  const mod = ModuleExecutor.from(sys, name);
141
145
  const files = await this.moduleRunner.createModuleTemplate(mod);
142
146
  if (page && sys.type === "app")
@@ -153,6 +157,7 @@ class ModuleScript extends script("module", [ModuleRunner, PageScript]) {
153
157
  await this.moduleRunner.removeModule(mod);
154
158
  }
155
159
  async createService(sys, name) {
160
+ assertPlainName("service", name);
156
161
  const service = ModuleExecutor.from(sys, `_${name}`);
157
162
  const files = await this.moduleRunner.createService(service);
158
163
  await sys.scan();
@@ -157,7 +157,7 @@ class SubagentPool2 {
157
157
  }
158
158
  }
159
159
  async#run(id, kind, prompt, signal) {
160
- const { CodeAgent } = await import("./CodeAgent-vmd9k4ak.js");
160
+ const { CodeAgent } = await import("./CodeAgent-fk66n37w.js");
161
161
  const budget = this.#options.parent.tools.subagent;
162
162
  const child = SubagentPool2.childOf(this.#options.parent, kind);
163
163
  const model = this.#options.model?.();
@@ -102,15 +102,8 @@ class PreviewView2 {
102
102
  settleMs = 0
103
103
  } = {}) {
104
104
  const logs = [];
105
- const view = PreviewView2.#open({ width, height, engine, onConsole: (line) => logs.push(line) });
105
+ const view = await PreviewView2.#start(() => PreviewView2.#open({ width, height, engine, onConsole: (line) => logs.push(line) }), engine, { startTimeoutMs, timeoutMs });
106
106
  try {
107
- const startMs = PreviewView2.#stalled.has(engine) ? Math.min(startTimeoutMs, timeoutMs) : startTimeoutMs;
108
- const stalled = new Error(`Timed out starting the ${engine} browser after ${startMs / 1000} s.`);
109
- await PreviewView2.#within(view.navigate("about:blank"), Date.now() + startMs, stalled).then(() => PreviewView2.#stalled.delete(engine), (error) => {
110
- if (error === stalled)
111
- PreviewView2.#stalled.add(engine);
112
- throw error;
113
- });
114
107
  const deadline = Date.now() + timeoutMs;
115
108
  const within = (work, what) => PreviewView2.#within(work, deadline, new Error(`Timed out ${what} ${url}; the dev server may be rebuilding or stuck.`));
116
109
  let page = await PreviewView2.#load(view, url, settleMs, within);
@@ -136,6 +129,28 @@ class PreviewView2 {
136
129
  await view.close();
137
130
  }
138
131
  }
132
+ static async#start(open, engine, { startTimeoutMs, timeoutMs }) {
133
+ for (let attempt = 1;; attempt++) {
134
+ const startMs = PreviewView2.#stalled.has(engine) ? Math.min(startTimeoutMs, timeoutMs) : startTimeoutMs;
135
+ const stalled = new Error(`Timed out starting the ${engine} browser after ${startMs / 1000} s.`);
136
+ let view;
137
+ try {
138
+ view = open();
139
+ await PreviewView2.#within(view.navigate("about:blank"), Date.now() + startMs, stalled);
140
+ PreviewView2.#stalled.delete(engine);
141
+ return view;
142
+ } catch (error) {
143
+ await view?.close();
144
+ if (error === stalled)
145
+ PreviewView2.#stalled.add(engine);
146
+ else
147
+ PreviewView2.#stalled.delete(engine);
148
+ if (error === stalled || attempt > 1)
149
+ throw error;
150
+ await Bun.sleep(100);
151
+ }
152
+ }
153
+ }
139
154
  static async#load(view, url, settleMs, within) {
140
155
  await within(view.navigate(url), "loading");
141
156
  if (settleMs > 0)
@@ -10,7 +10,7 @@ import {
10
10
  isScannedRootEntry,
11
11
  AppExecutor,
12
12
  LibExecutor
13
- } from "./index-sr5da35e.js";
13
+ } from "./index-sq9d0jhj.js";
14
14
  import {
15
15
  FileSys2
16
16
  } from "./index-bns3wcpc.js";
@@ -23,12 +23,33 @@ import {
23
23
  workflowPathsForPlan,
24
24
  workflowRunArtifactPath,
25
25
  workflowSyncDir
26
- } from "./index-8pb9yvp8.js";
26
+ } from "./index-dfsa009c.js";
27
27
 
28
28
  // pkgs/@akanjs/devkit/akanContext.ts
29
29
  import { readdir } from "fs/promises";
30
30
  import path from "path";
31
31
  import { capitalize, isRecord, parseRouteModuleKey } from "akanjs/common";
32
+
33
+ // pkgs/@akanjs/devkit/moduleFieldNames.ts
34
+ import ts from "typescript";
35
+ var isFieldCall = (node) => ts.isCallExpression(node) && (ts.isIdentifier(node.expression) ? node.expression.text === "field" : ts.isPropertyAccessExpression(node.expression) && isFieldCall(node.expression.expression));
36
+ var propertyNames = (content, declares) => {
37
+ const names = [];
38
+ const visit = (node) => {
39
+ if (ts.isPropertyAssignment(node) && ts.isIdentifier(node.name) && declares(node.initializer))
40
+ names.push(node.name.text);
41
+ ts.forEachChild(node, visit);
42
+ };
43
+ visit(ts.createSourceFile("module.ts", content, ts.ScriptTarget.Latest));
44
+ return names;
45
+ };
46
+ var constantFieldNames = (content) => propertyNames(content, isFieldCall);
47
+ var unlabeledFieldNames = (constantContent, dictionaryContent) => {
48
+ const labels = new Set(propertyNames(dictionaryContent, () => true));
49
+ return constantFieldNames(constantContent).filter((name) => !labels.has(name));
50
+ };
51
+
52
+ // pkgs/@akanjs/devkit/akanContext.ts
32
53
  var guidelineResourceUri = (name) => `akan://guidelines/${name}`;
33
54
  var staticResourceList = [
34
55
  { uri: "akan://docs/framework", name: "Akan framework guide", mimeType: "text/markdown" },
@@ -165,7 +186,6 @@ var moduleShapeFiles = (module) => {
165
186
  `${module.name}.signal.ts`
166
187
  ];
167
188
  };
168
- var constantFieldNames = (content) => [...content.matchAll(/\b([A-Za-z_$][\w$]*)\s*:\s*field\(/g)].map((match) => match[1]).filter(Boolean);
169
189
  var safeReadDir = async (dirPath) => (await readdir(dirPath, { withFileTypes: true }).catch(() => [])).sort((a, b) => a.name.localeCompare(b.name));
170
190
  var safeReadText = (filePath) => FileSys2.readText(filePath).catch(() => null);
171
191
  var safeReadJson = (filePath) => FileSys2.readJson(filePath).catch(() => null);
@@ -531,9 +551,7 @@ class AkanContextAnalyzer {
531
551
  safeReadText(dictionaryPath)
532
552
  ]);
533
553
  if (constantContent && dictionaryContent) {
534
- for (const fieldName of constantFieldNames(constantContent)) {
535
- if (new RegExp(`\\b${fieldName}\\s*:`).test(dictionaryContent))
536
- continue;
554
+ for (const fieldName of unlabeledFieldNames(constantContent, dictionaryContent)) {
537
555
  report({
538
556
  severity: "warning",
539
557
  code: "dictionary-label-missing",
@@ -14,12 +14,12 @@ import {
14
14
  import {
15
15
  PreviewView2,
16
16
  stripAnsi
17
- } from "./index-23860fej.js";
17
+ } from "./index-b4qq3rq0.js";
18
18
  import {
19
19
  SubagentPool2,
20
20
  McpSignIn,
21
21
  AkanCodeCompaction2
22
- } from "./index-8kczhnmv.js";
22
+ } from "./index-b3pr4ee6.js";
23
23
  import {
24
24
  codeAgentIsLoopback,
25
25
  codeAgentHostListed,
@@ -659,7 +659,7 @@ class AkanToolPack2 {
659
659
  return { name: "akan-tools", factory: async (pi) => await this.#register(pi) };
660
660
  }
661
661
  async names() {
662
- const { ContextRunner } = await import("./context.runner-ms8v1rxy.js");
662
+ const { ContextRunner } = await import("./context.runner-w071gmc3.js");
663
663
  return [
664
664
  ...new ContextRunner().listMcpTools(this.#options.mode).map((tool) => tool.name),
665
665
  AkanToolPack2.verifyToolName
@@ -667,7 +667,7 @@ class AkanToolPack2 {
667
667
  }
668
668
  static verifyToolName = "akan_verify";
669
669
  async#register(pi) {
670
- const { ContextRunner } = await import("./context.runner-ms8v1rxy.js");
670
+ const { ContextRunner } = await import("./context.runner-w071gmc3.js");
671
671
  const runner = new ContextRunner;
672
672
  const guidelineNames = await AkanToolPack2.#guidelineNames();
673
673
  for (const tool of runner.listMcpTools(this.#options.mode, { guidelineNames })) {
@@ -854,6 +854,7 @@ import {
854
854
  import { Type as Type4 } from "typebox";
855
855
 
856
856
  // pkgs/@akanjs/devkit/codeAgent/tools/McpClient.ts
857
+ import { FailureCode, MCP_FAILURE_META } from "akanjs/common";
857
858
  var protocolVersion = "2025-06-18";
858
859
 
859
860
  class McpUnauthorized2 extends Error {
@@ -909,8 +910,14 @@ class McpClient2 {
909
910
  async callTool(name, args) {
910
911
  const response = await this.#call("tools/call", { name, arguments: args });
911
912
  if (response.error)
912
- return { text: response.error.message, isError: true };
913
- return { text: McpClient2.#renderContent(response.result?.content), isError: !!response.result?.isError };
913
+ return { text: response.error.message, isError: true, ...McpClient2.#coded(response.error.data) };
914
+ const isError = !!response.result?.isError;
915
+ const failure = isError ? response.result?._meta?.[MCP_FAILURE_META] : undefined;
916
+ return { text: McpClient2.#renderContent(response.result?.content), isError, ...McpClient2.#coded(failure) };
917
+ }
918
+ static #coded(carrier) {
919
+ const code = carrier && typeof carrier === "object" ? carrier.code : undefined;
920
+ return FailureCode.is(code) ? { code } : {};
914
921
  }
915
922
  close() {
916
923
  this.#proc?.kill();
@@ -1098,7 +1105,7 @@ class McpToolPack2 {
1098
1105
  const result = await this.#call(server, tool.name, params ?? {});
1099
1106
  return {
1100
1107
  content: [{ type: "text", text: codeAgentClip(result.text, codeAgentOutputChars) }],
1101
- details: undefined,
1108
+ details: result.code === undefined ? undefined : { code: result.code },
1102
1109
  isError: result.isError
1103
1110
  };
1104
1111
  }
@@ -1,19 +1,21 @@
1
1
  // @bun
2
+ import {
3
+ AkanContextAnalyzer
4
+ } from "./index-bper31wr.js";
2
5
  import {
3
6
  writeWorkflowRunArtifact,
4
7
  generatedFilePathsForTarget,
5
8
  writeGeneratedSyncState,
6
9
  createRepairReport,
7
- isWorkflowSysName,
8
- isWorkflowModuleName,
9
10
  renderRepairReport
10
- } from "./index-8pb9yvp8.js";
11
- import {
12
- AkanContextAnalyzer
13
- } from "./index-thckcabc.js";
11
+ } from "./index-dfsa009c.js";
14
12
  import {
15
13
  runner
16
- } from "./index-93ewzmp6.js";
14
+ } from "./index-23d8gw08.js";
15
+ import {
16
+ isWorkflowSysName,
17
+ isWorkflowModuleName
18
+ } from "./index-va90m8nd.js";
17
19
 
18
20
  // pkgs/@akanjs/cli/repair/repair.runner.ts
19
21
  var akanArgPattern = /^(?:--?[a-z][a-zA-Z0-9-]*|[A-Za-z0-9@_][A-Za-z0-9@._/:,=-]*)$/;
@@ -2,14 +2,18 @@
2
2
  import {
3
3
  AppExecutor,
4
4
  LibExecutor
5
- } from "./index-sr5da35e.js";
5
+ } from "./index-sq9d0jhj.js";
6
6
  import {
7
7
  createAst,
8
8
  AkanIndex
9
- } from "./index-7y5yghjg.js";
9
+ } from "./index-nd39rssn.js";
10
+ import {
11
+ sysNamePattern,
12
+ identifierPattern
13
+ } from "./index-va90m8nd.js";
10
14
  import {
11
15
  camelToKebabCase
12
- } from "./index-93ewzmp6.js";
16
+ } from "./index-23d8gw08.js";
13
17
 
14
18
  // pkgs/@akanjs/devkit/workflow/artifacts.ts
15
19
  import { capitalize as capitalize2 } from "akanjs/common";
@@ -180,11 +184,9 @@ var createWorkflowApplyReport = ({
180
184
  nextActions = [],
181
185
  plan
182
186
  }) => {
183
- const validationCommands = recommendedValidationCommands ?? commands;
184
- const nextActionsWithIntent = nextActions.map((action) => ({
185
- ...action,
186
- action: inferNextActionCode(action, diagnostics)
187
- }));
187
+ const status = workflowStatus(diagnostics);
188
+ const validationCommands = status === "failed" ? [] : recommendedValidationCommands ?? commands;
189
+ const nextActionsWithIntent = nextActions.map((action) => ({ ...action, action: inferNextActionCode(action, diagnostics) })).filter((action) => status !== "failed" || action.action !== "validate");
188
190
  if (sourceChangeBlocked(diagnostics) && !nextActionsWithIntent.some((action) => action.action === "blocked")) {
189
191
  nextActionsWithIntent.unshift({
190
192
  command: `akan workflow explain ${workflow}`,
@@ -194,12 +196,12 @@ var createWorkflowApplyReport = ({
194
196
  }
195
197
  const orderedNextActions = uniqueBy(nextActionsWithIntent, (action) => action.command).sort((left, right) => nextActionPriority(left, diagnostics) - nextActionPriority(right, diagnostics));
196
198
  const sourceFilesChanged = uniqueBy(changedFiles, (file) => `${file.action}:${file.path}:${file.reason}`);
197
- const generatedFilesSynced = uniqueBy(generatedFiles, (file) => `${file.action}:${file.path}:${file.reason}`);
199
+ const generatedFilesSynced = status === "failed" ? [] : uniqueBy(generatedFiles, (file) => `${file.action}:${file.path}:${file.reason}`);
198
200
  return {
199
201
  schemaVersion: 1,
200
202
  workflow,
201
203
  mode,
202
- status: workflowStatus(diagnostics),
204
+ status,
203
205
  summary: {
204
206
  sourceFilesChanged,
205
207
  generatedFilesSynced
@@ -216,6 +218,7 @@ var createWorkflowApplyReport = ({
216
218
  plan
217
219
  };
218
220
  };
221
+ var withoutApplyHints = (recommendations) => recommendations.filter((recommendation) => recommendation.kind !== "auto-apply" && recommendation.kind !== "validation");
219
222
  var resolveWorkflowCommand = (command, plan) => {
220
223
  const target = typeof plan.inputs.app === "string" ? plan.inputs.app : "<app-or-lib>";
221
224
  return command.replaceAll("<app-or-lib-or-pkg>", target).replaceAll("<app-or-lib>", target).replaceAll("<app-name>", target);
@@ -455,6 +458,17 @@ var createWorkflowValidationRunReport = async ({
455
458
  };
456
459
  };
457
460
  var createDryRunWorkflowApplyReport = (plan) => {
461
+ if (workflowStatus(plan.diagnostics) === "failed")
462
+ return createWorkflowApplyReport({
463
+ workflow: plan.workflow,
464
+ mode: "dry-run",
465
+ changedFiles: [],
466
+ generatedFiles: [],
467
+ diagnostics: [...plan.diagnostics],
468
+ recommendations: withoutApplyHints(plan.recommendations),
469
+ nextActions: [],
470
+ plan
471
+ });
458
472
  const changedFiles = plan.predictedChanges.flatMap((change) => {
459
473
  if (change.action !== "create" && change.action !== "modify")
460
474
  return [];
@@ -705,11 +719,6 @@ ${line}
705
719
  `);
706
720
  };
707
721
  var ensureBaseImport = (content, name) => ensureNamedImport(content, "akanjs/base", name);
708
- var ensureBaseTypeImport = (content, typeName) => {
709
- if (typeName !== "Int" && typeName !== "Float")
710
- return content;
711
- return ensureBaseImport(content, typeName);
712
- };
713
722
  var numericDefault = (typeName, rawDefault) => {
714
723
  if (typeof rawDefault === "number") {
715
724
  if (!Number.isFinite(rawDefault))
@@ -2299,6 +2308,87 @@ class WorkflowExecutor {
2299
2308
  return report();
2300
2309
  }
2301
2310
  }
2311
+ // pkgs/@akanjs/devkit/workflow/fieldType.ts
2312
+ import ts5 from "typescript";
2313
+ var builtInFieldTypes = new Set(["String", "Boolean", "Date", "Map"]);
2314
+ var baseFieldTypes = new Set(["Int", "Float", "ID", "Any", "Binary", "ImageResult"]);
2315
+ var fieldTypeReference = /^\[*([A-Za-z_$][\w$]*)((?:\.[A-Za-z_$][\w$]*)*)\]*$/;
2316
+ var ensureBaseTypeImport = (content, typeName) => {
2317
+ const [, name = "", member] = fieldTypeReference.exec(typeName) ?? [];
2318
+ if (member || !baseFieldTypes.has(name))
2319
+ return content;
2320
+ return ensureBaseImport(content, name);
2321
+ };
2322
+ var valueNamesOf = (content) => {
2323
+ const names = new Set;
2324
+ for (const statement of sourceFileFor("source.ts", content).statements) {
2325
+ if (ts5.isImportDeclaration(statement)) {
2326
+ const clause = statement.importClause;
2327
+ if (!clause || clause.isTypeOnly)
2328
+ continue;
2329
+ if (clause.name)
2330
+ names.add(clause.name.text);
2331
+ const bindings = clause.namedBindings;
2332
+ if (bindings && ts5.isNamespaceImport(bindings))
2333
+ names.add(bindings.name.text);
2334
+ else
2335
+ for (const element of bindings?.elements ?? [])
2336
+ if (!element.isTypeOnly)
2337
+ names.add(element.name.text);
2338
+ } else if (ts5.isVariableStatement(statement)) {
2339
+ for (const declaration of statement.declarationList.declarations)
2340
+ if (ts5.isIdentifier(declaration.name))
2341
+ names.add(declaration.name.text);
2342
+ } else if ((ts5.isClassDeclaration(statement) || ts5.isEnumDeclaration(statement) || ts5.isFunctionDeclaration(statement)) && statement.name)
2343
+ names.add(statement.name.text);
2344
+ }
2345
+ return names;
2346
+ };
2347
+ var fieldTypeSource = async (sys, module, typeName, constantContent) => {
2348
+ const reference = fieldTypeReference.exec(typeName);
2349
+ if (!reference)
2350
+ return {
2351
+ diagnostic: {
2352
+ severity: "error",
2353
+ code: "primitive-field-type-unknown",
2354
+ input: "type",
2355
+ message: `Field type "${typeName}" is not a type name field() takes. Name one type, such as Address, or a list of one, such as [Address], then plan this again.`
2356
+ }
2357
+ };
2358
+ const [, name = "", member] = reference;
2359
+ if (builtInFieldTypes.has(name) || baseFieldTypes.has(name) || valueNamesOf(constantContent).has(name))
2360
+ return {};
2361
+ const [scalars, models] = await Promise.all([sys.getScalarModules(), sys.getDatabaseModules()]);
2362
+ const scalar = member ? undefined : scalars.find((scalarName) => moduleComponentName(scalarName) === name);
2363
+ if (scalar)
2364
+ return { import: { name, from: `../__scalar/${scalar}/${scalar}.constant` } };
2365
+ const model = member ? undefined : models.find((modelName) => moduleComponentName(modelName) === name);
2366
+ if (model)
2367
+ return { import: { name, from: `../${model}/${model}.constant` } };
2368
+ const root = getSysRoot(sys);
2369
+ const constantPath = `${root}/${moduleSourcePaths(module).constant}`;
2370
+ const named = (kind, names) => names.length ? `Its ${kind} are ${names.map(moduleComponentName).join(", ")}.` : `It has no ${kind}.`;
2371
+ return {
2372
+ diagnostic: {
2373
+ severity: "error",
2374
+ code: "primitive-field-type-unknown",
2375
+ input: "type",
2376
+ message: [
2377
+ `Field type "${typeName}" names ${name}, which is not a built-in or akanjs/base type, not imported by ${constantPath}, and not a scalar or model in ${root}.`,
2378
+ named("scalars", scalars),
2379
+ named("models", models),
2380
+ `Create the scalar with the create-scalar workflow first, or import ${name} into ${constantPath}, then plan this again.`
2381
+ ].join(" ")
2382
+ }
2383
+ };
2384
+ };
2385
+ var withFieldTypeImport = async (sys, module, typeName, content, diagnostics) => {
2386
+ const withBaseImport = ensureBaseTypeImport(content, typeName);
2387
+ const source = await fieldTypeSource(sys, module, typeName, withBaseImport);
2388
+ if (source.diagnostic)
2389
+ diagnostics.push(source.diagnostic);
2390
+ return source.import ? ensureNamedImport(withBaseImport, source.import.from, source.import.name) : withBaseImport;
2391
+ };
2302
2392
  // pkgs/@akanjs/devkit/workflow/guardCatalog.ts
2303
2393
  class GuardCatalog {
2304
2394
  static frameworkGuards = ["Public"];
@@ -2379,7 +2469,7 @@ class GuardCatalog {
2379
2469
  // pkgs/@akanjs/devkit/workflow/keyRename.ts
2380
2470
  import { readFile } from "fs/promises";
2381
2471
  import path2 from "path";
2382
- import ts5 from "typescript";
2472
+ import ts6 from "typescript";
2383
2473
  var indexedPath = /^(apps|libs)\/(?!(?:.*\/)?(?:node_modules|dist|\.akan)\/).*\.tsx?$/;
2384
2474
  var keyPattern = /^[a-z][A-Za-z0-9]*$/;
2385
2475
  var slashed = (fileName) => fileName.replace(/\\/g, "/");
@@ -2408,7 +2498,7 @@ class KeyRename {
2408
2498
  const sourceRelative = `${getSysRoot(sys)}/${family === "slice" ? paths.signal : paths.document}`;
2409
2499
  const sourcePath = slashed(path2.join(root, sourceRelative));
2410
2500
  const texts = new Map;
2411
- const index = new AkanIndex({ ts: ts5, root });
2501
+ const index = new AkanIndex({ ts: ts6, root });
2412
2502
  for (const relative of await workspace.getAllFiles("{apps,libs}/**/*.{ts,tsx}")) {
2413
2503
  if (!indexedPath.test(slashed(relative)))
2414
2504
  continue;
@@ -3003,8 +3093,6 @@ class MutationScaffold {
3003
3093
  // pkgs/@akanjs/devkit/workflow/plan.ts
3004
3094
  import { capitalize as capitalize4 } from "akanjs/common";
3005
3095
  var surfaceModes = new Set(["infer", "include", "skip"]);
3006
- var sysNamePattern = /^[a-z0-9][a-zA-Z0-9_-]*$/;
3007
- var identifierPattern = /^_{0,2}[a-zA-Z][a-zA-Z0-9_-]*$/;
3008
3096
  var nameInputPatterns = {
3009
3097
  app: sysNamePattern,
3010
3098
  module: identifierPattern,
@@ -3016,8 +3104,6 @@ var nameInputPatterns = {
3016
3104
  mutation: identifierPattern,
3017
3105
  interaction: identifierPattern
3018
3106
  };
3019
- var isWorkflowSysName = (value) => typeof value === "string" && sysNamePattern.test(value);
3020
- var isWorkflowModuleName = (value) => typeof value === "string" && identifierPattern.test(value);
3021
3107
  var parseStringList = (value) => {
3022
3108
  if (Array.isArray(value)) {
3023
3109
  const values = value.filter((item) => typeof item === "string" && item.trim().length > 0);
@@ -3397,28 +3483,53 @@ var inspectRenameKeyPlan = async (workspace, plan) => {
3397
3483
  var syssHolding = async (workspace, module, except) => {
3398
3484
  const [apps, libs] = await workspace.getSyss();
3399
3485
  const others = await Promise.all([...apps, ...libs].filter((name) => name !== except.name).map(async (name) => await resolveWorkflowSys(workspace, name)));
3400
- const holding = await Promise.all(others.map(async (other) => other && (await other.readdir("lib")).includes(module) ? other : null));
3486
+ const holding = await Promise.all(others.map(async (other) => other && (await other.getDatabaseModules()).includes(module) ? other : null));
3401
3487
  return holding.filter((other) => other !== null);
3402
3488
  };
3403
3489
  var moduleMissing = async (workspace, sys, module) => {
3404
3490
  if ((await sys.readdir("lib")).includes(module))
3405
3491
  return null;
3406
3492
  const root = getSysRoot(sys);
3407
- const modules = [...await sys.getDatabaseModules(), ...await sys.getServiceModules()];
3408
- const sameName = modules.find((name) => name.replace(/^_/, "").toLowerCase() === module.toLowerCase());
3493
+ const modules = await sys.getDatabaseModules();
3494
+ const sameName = modules.find((name) => name.toLowerCase() === module.toLowerCase());
3495
+ const service = (await sys.getServiceModules()).find((name) => name.replace(/^_/, "").toLowerCase() === module.replace(/^_/, "").toLowerCase());
3409
3496
  const isScalar = (await sys.getScalarModules()).includes(module);
3410
- const [holder] = sameName || isScalar ? [] : await syssHolding(workspace, module, sys);
3497
+ const [holder] = sameName || service || isScalar ? [] : await syssHolding(workspace, module, sys);
3411
3498
  return {
3412
3499
  severity: "error",
3413
3500
  code: "workflow-module-missing",
3414
3501
  input: "module",
3415
3502
  message: [
3416
3503
  `No module named ${module} in ${root}: ${root}/lib/${module} does not exist.`,
3417
- modules.length ? `Its modules are ${modules.join(", ")}.` : `${root} has no modules yet.`,
3418
- sameName ? `Did you mean ${sameName}?` : isScalar ? `${root}/lib/__scalar/${module} is a scalar, and this workflow writes only into a module under ${root}/lib.` : holder ? `${module} is in ${getSysRoot(holder)}, so plan this with --app ${holder.name}.` : `If ${module} is a new model, create it with the create-module workflow first, then plan this again.`
3504
+ modules.length ? `Its database modules are ${modules.join(", ")}.` : `${root} has no database modules yet.`,
3505
+ sameName ? `Did you mean ${sameName}?` : service ? `${root}/lib/${service} is a service module, which stores no model, and this workflow writes only into a database module.` : isScalar ? `${root}/lib/__scalar/${module} is a scalar, and this workflow writes only into a module under ${root}/lib.` : holder ? `${module} is in ${getSysRoot(holder)}, so plan this with --app ${holder.name}.` : `If ${module} is a new model, create it with the create-module workflow first, then plan this again.`
3419
3506
  ].join(" ")
3420
3507
  };
3421
3508
  };
3509
+ var moduleNotDatabase = async (sys, spec, module) => {
3510
+ const databaseModules = await sys.getDatabaseModules();
3511
+ if (databaseModules.includes(module))
3512
+ return null;
3513
+ const root = getSysRoot(sys);
3514
+ const isServiceModule = module.startsWith("_") && !module.startsWith("__");
3515
+ return {
3516
+ severity: "error",
3517
+ code: "workflow-module-not-database",
3518
+ input: "module",
3519
+ message: [
3520
+ isServiceModule ? `${module} in ${root} is a service module, which stores no model.` : `${root}/lib/${module} is not a database module: it has no ${module}.constant.ts.`,
3521
+ `${spec.name} needs a database module, one with lib/<model>/<model>.constant.ts.`,
3522
+ databaseModules.length ? `Its database modules are ${databaseModules.join(", ")}.` : `${root} has no database modules yet.`,
3523
+ spec.inputs.field ? "Add the field to one of them, or create its model with the create-module workflow first; a value several models embed is a scalar, made with create-scalar and added to a model as a field of that type." : "Plan this on one of them, or create the model with the create-module workflow first."
3524
+ ].join(" ")
3525
+ };
3526
+ };
3527
+ var fieldTypeUnknown = async (sys, spec, module, type) => {
3528
+ if (spec.name !== "add-field" || !type || ["enum", "number", "numeric", "upload"].includes(type.toLowerCase()))
3529
+ return null;
3530
+ const constant = await sys.readFile(moduleSourcePaths(module).constant);
3531
+ return (await fieldTypeSource(sys, module, normalizeFieldType(type), constant)).diagnostic ?? null;
3532
+ };
3422
3533
  var workflowTargetDiagnostics = async (workspace, spec, inputs) => {
3423
3534
  const app = planString(inputs, "app");
3424
3535
  if (!app)
@@ -3439,10 +3550,10 @@ var workflowTargetDiagnostics = async (workspace, spec, inputs) => {
3439
3550
  const moduleSpec = spec.inputs.module;
3440
3551
  if (!module || !moduleSpec?.mustExist)
3441
3552
  return [];
3442
- const missing = await moduleMissing(workspace, sys, module);
3443
- return missing ? [missing] : [];
3553
+ const refused = await moduleMissing(workspace, sys, module) ?? await moduleNotDatabase(sys, spec, module) ?? await fieldTypeUnknown(sys, spec, module, planString(inputs, "type"));
3554
+ return refused ? [refused] : [];
3444
3555
  };
3445
- var inspectWorkflowPlan = async (workspace, spec, plan) => {
3556
+ var inspectPlanTarget = async (workspace, spec, plan) => {
3446
3557
  const targetDiagnostics = await workflowTargetDiagnostics(workspace, spec, plan.inputs);
3447
3558
  if (targetDiagnostics.length)
3448
3559
  return {
@@ -3475,6 +3586,12 @@ var inspectWorkflowPlan = async (workspace, spec, plan) => {
3475
3586
  recommendations: [...plan.recommendations, ...inspected.recommendations]
3476
3587
  };
3477
3588
  };
3589
+ var inspectWorkflowPlan = async (workspace, spec, plan) => {
3590
+ const inspected = await inspectPlanTarget(workspace, spec, plan);
3591
+ if (workflowStatus(inspected.diagnostics) === "passed")
3592
+ return inspected;
3593
+ return { ...inspected, recommendations: withoutApplyHints(inspected.recommendations) };
3594
+ };
3478
3595
  // pkgs/@akanjs/devkit/workflow/render.ts
3479
3596
  var listOr = (items, render, empty = "- none") => items?.length ? items.map(render) : [empty];
3480
3597
  var renderDiagnostic = (diagnostic) => `- [${diagnostic.severity}] ${diagnostic.code}: ${diagnostic.message}`;
@@ -3802,4 +3919,4 @@ for (const candidate of toolingRolloutCandidates) {
3802
3919
  if (isRestrictedCandidate(candidate))
3803
3920
  restrictedCandidates.set(candidate.packageName, candidate);
3804
3921
  }
3805
- export { InteractionScaffold, jsonText, workflowStatus, compactDiagnostics, workflowPlanApproval, createWorkflowApplyReport, workflowCommandsForPlan, workflowPathsForPlan, workflowRunArtifactPath, writeWorkflowRunArtifact, workflowSyncDir, generatedFilePathsForTarget, writeGeneratedSyncState, readWorkflowRunArtifact, createWorkflowBaselineSummary, createWorkflowValidationRunReport, createDryRunWorkflowApplyReport, createRepairReport, sourceFile, moduleComponentName, moduleSourcePaths, generatedFilesForSync, validationCommandsForTarget, nextActionsForTarget, createPrimitiveWriteReport, createPassedPrimitiveReport, scalarChangedFiles, bilingualLabelForField, bilingualDescriptionForField, normalizeFieldType, ensureNamedImport, ensureBaseImport, ensureBaseTypeImport, coerceFieldDefault, fieldExpression, viaBuilderParameterName, insertIntoObject, insertLightProjectionField, insertTemplateField, ensureEnumImport, insertEnumClass, insertDictionaryModelField, hasConstantInputField, hasDictionaryModelField, ensureConstantTypeImport, insertDictionaryEnum, parseValues, hasSourceParseErrors, hasClassMethod, insertClassMethod, hasSignalFactoryEntry, insertSignalFactoryEntry, buildAkanModuleContextIndex, addFieldUiPolicyForType, createWorkflowStepRegistry, WorkflowExecutor, KeyRename, MutationScaffold, isWorkflowSysName, isWorkflowModuleName, listWorkflowSpecs, getWorkflowSpec, compactWorkflowInputs, createWorkflowPlan, workflowTargetDiagnostics, inspectWorkflowPlan, renderWorkflowList, renderWorkflowExplain, renderWorkflowPlan, renderWorkflowApply, renderWorkflowValidation, renderRepairReport, renderWorkflowRunArtifact, renderPrimitiveReport, toolingRolloutGate };
3922
+ export { InteractionScaffold, jsonText, workflowStatus, compactDiagnostics, workflowPlanApproval, createWorkflowApplyReport, workflowCommandsForPlan, workflowPathsForPlan, workflowRunArtifactPath, writeWorkflowRunArtifact, workflowSyncDir, generatedFilePathsForTarget, writeGeneratedSyncState, readWorkflowRunArtifact, createWorkflowBaselineSummary, createWorkflowValidationRunReport, createDryRunWorkflowApplyReport, createRepairReport, sourceFile, moduleComponentName, moduleSourcePaths, generatedFilesForSync, validationCommandsForTarget, nextActionsForTarget, createPrimitiveWriteReport, createPassedPrimitiveReport, scalarChangedFiles, bilingualLabelForField, bilingualDescriptionForField, normalizeFieldType, ensureNamedImport, ensureBaseImport, coerceFieldDefault, fieldExpression, viaBuilderParameterName, insertIntoObject, insertLightProjectionField, insertTemplateField, ensureEnumImport, insertEnumClass, insertDictionaryModelField, hasConstantInputField, hasDictionaryModelField, ensureConstantTypeImport, insertDictionaryEnum, parseValues, hasSourceParseErrors, hasClassMethod, insertClassMethod, hasSignalFactoryEntry, insertSignalFactoryEntry, buildAkanModuleContextIndex, addFieldUiPolicyForType, createWorkflowStepRegistry, WorkflowExecutor, withFieldTypeImport, KeyRename, MutationScaffold, listWorkflowSpecs, getWorkflowSpec, compactWorkflowInputs, createWorkflowPlan, workflowTargetDiagnostics, inspectWorkflowPlan, renderWorkflowList, renderWorkflowExplain, renderWorkflowPlan, renderWorkflowApply, renderWorkflowValidation, renderRepairReport, renderWorkflowRunArtifact, renderPrimitiveReport, toolingRolloutGate };
@@ -5,17 +5,17 @@ import {
5
5
  AkanAppConfig,
6
6
  Executor,
7
7
  WorkspaceExecutor
8
- } from "./index-sr5da35e.js";
8
+ } from "./index-sq9d0jhj.js";
9
9
  import {
10
10
  resolveAppId,
11
11
  targetHtmlFilename
12
12
  } from "./index-m9jj544v.js";
13
13
  import {
14
14
  CsrArtifactBuilder
15
- } from "./index-mmym5xmb.js";
15
+ } from "./index-z43wddce.js";
16
16
  import {
17
17
  ExitCodeError
18
- } from "./index-93ewzmp6.js";
18
+ } from "./index-23d8gw08.js";
19
19
 
20
20
  // pkgs/@akanjs/devkit/mobile/desktopBin.ts
21
21
  import { chmod, mkdir, rename, rm, writeFile } from "fs/promises";