@akanjs/cli 3.1.1-rc.14 → 3.1.1-rc.16

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 (71) hide show
  1. package/.build-stamp +1 -1
  2. package/{CodeAgent-gtwn7tmb.js → CodeAgent-23ewzxqa.js} +2 -2
  3. package/{CodeTui-v941fqdh.js → CodeTui-kc99fk78.js} +1 -1
  4. package/TunnelShare-dk2gw78d.js +14 -0
  5. package/{agent.command-h82gepwn.js → agent.command-knp5j7bq.js} +5 -5
  6. package/akanCode.js +2 -2
  7. package/{application.command-j1reb9p1.js → application.command-bvfd1680.js} +9 -9
  8. package/{applicationBuildRunner-w20x63mz.js → applicationBuildRunner-4ajaesk1.js} +6 -5
  9. package/buildBatch.proc.js +5 -5
  10. package/{cloud.command-zd2mfkm0.js → cloud.command-f2w40fyy.js} +13 -13
  11. package/cloud.script-2r82sv0f.js +24 -0
  12. package/{code.command-dyet4xn6.js → code.command-dbhhnahn.js} +6 -6
  13. package/{context.command-79gxczm4.js → context.command-yswjwv6y.js} +17 -16
  14. package/context.runner-c3wsh2jw.js +26 -0
  15. package/{guideline.command-xwkskvky.js → guideline.command-ztx6dkpk.js} +2 -2
  16. package/guidelines/conventions/conventions.instruction.md +56 -10
  17. package/incrementalBuilder.proc.js +3 -3
  18. package/{index-yknrmkmt.js → index-005dqc83.js} +2 -2
  19. package/{index-qmeh0s05.js → index-00ke4phc.js} +2 -2
  20. package/{index-hdzjaq7s.js → index-2epb3wgh.js} +2 -2
  21. package/{index-rshwdv9w.js → index-2p1brf5e.js} +2 -2
  22. package/{index-wvvwdzfw.js → index-4332q6yj.js} +3 -3
  23. package/{index-6pzt55w3.js → index-4t4qb8jg.js} +3 -3
  24. package/{index-7ktk2hnz.js → index-76jwsm3g.js} +2 -2
  25. package/{index-tzzs52h0.js → index-7ndgffg4.js} +9 -9
  26. package/{index-1e2955yd.js → index-921cxqrd.js} +3 -1
  27. package/{index-8jb5ep2e.js → index-97fsvy66.js} +2 -2
  28. package/{index-pc9ps0hx.js → index-9sa6abze.js} +8 -8
  29. package/{index-jjd97ya6.js → index-deeskxjh.js} +1 -1
  30. package/{index-cz9g85xh.js → index-er16p89s.js} +1 -1
  31. package/{index-ygy8c12j.js → index-gxj80jz7.js} +1 -1
  32. package/index-hvg3esm0.js +1844 -0
  33. package/{index-41d3zx66.js → index-k9k18vq9.js} +3 -3
  34. package/{index-nmy1rana.js → index-m54n0v29.js} +4 -4
  35. package/index-m5n3ka0p.js +18 -0
  36. package/{index-brpk7gd8.js → index-m6qgr1rx.js} +7 -7
  37. package/{index-553xyb55.js → index-m93qg20j.js} +1 -1
  38. package/{index-4rwfh2de.js → index-mk391h0z.js} +3 -3
  39. package/{index-ch1sv7ke.js → index-nzfgyw3b.js} +9 -21
  40. package/{index-2qzzp0c9.js → index-p2pahmsa.js} +3 -3
  41. package/{index-kbbyzs6j.js → index-qx4r4cj2.js} +2 -2
  42. package/index-rxse80x6.js +408 -0
  43. package/{index-kr62ph5a.js → index-s4c2y5gs.js} +2 -2
  44. package/{index-jtydvvq7.js → index-saj9cx3a.js} +4 -4
  45. package/index-vgt25eh1.js +615 -0
  46. package/{index-8rvwgd1r.js → index-vq77g679.js} +1 -1
  47. package/{index-xeh7m2j5.js → index-xfp4dcnx.js} +1 -1
  48. package/{index-pqdz7rat.js → index-xjwcp91m.js} +910 -36
  49. package/{index-7abjzny1.js → index-ysyt782g.js} +33 -37
  50. package/index.js +22 -22
  51. package/{library.command-td8t85kb.js → library.command-hmbkcwzw.js} +3 -3
  52. package/{localRegistry.command-jx9zkmxf.js → localRegistry.command-sq5p4c9x.js} +15 -13
  53. package/{module.command-j70mqgpp.js → module.command-n4z29zcv.js} +5 -5
  54. package/{package.command-1b1v6k5v.js → package.command-20025dy3.js} +3 -3
  55. package/package.json +2 -2
  56. package/{page.command-m31w2tsz.js → page.command-q8fvpjer.js} +3 -3
  57. package/{pipeline.command-q7b8wy55.js → pipeline.command-8j97fq88.js} +2 -2
  58. package/{primitive.command-4zrbhkb9.js → primitive.command-e5y6dqp1.js} +6 -6
  59. package/{projectTypecheck-synx6qff.js → projectTypecheck-tbdye9k3.js} +1 -1
  60. package/{quality.command-cy0pgqjz.js → quality.command-168pt5vm.js} +621 -311
  61. package/{repair.command-98n6zxg7.js → repair.command-dq1gckth.js} +5 -5
  62. package/{scalar.command-rak5pjk3.js → scalar.command-5vwf152w.js} +4 -4
  63. package/{subspace.command-ej0rk116.js → subspace.command-182be8vj.js} +8 -8
  64. package/{tunnel.command-kdx3amrc.js → tunnel.command-bfzj7xkb.js} +7 -7
  65. package/{workflow.command-gffk9nj9.js → workflow.command-3g53242s.js} +37 -13
  66. package/workspace.command-h7399jwv.js +260 -0
  67. package/TunnelShare-26ty9skr.js +0 -14
  68. package/cloud.script-vdj8ymch.js +0 -24
  69. package/context.runner-ejag7mhr.js +0 -25
  70. package/index-y5m4j2w6.js +0 -856
  71. package/workspace.command-097hv6n1.js +0 -521
@@ -2,10 +2,121 @@
2
2
  import {
3
3
  AppExecutor,
4
4
  LibExecutor
5
- } from "./index-1e2955yd.js";
5
+ } from "./index-921cxqrd.js";
6
6
 
7
7
  // pkgs/@akanjs/devkit/workflow/artifacts.ts
8
- import { capitalize } from "akanjs/common";
8
+ import { capitalize as capitalize2 } from "akanjs/common";
9
+
10
+ // pkgs/@akanjs/devkit/workflow/interactionScaffold.ts
11
+ import { capitalize, lowerlize } from "akanjs/common";
12
+
13
+ class InteractionScaffold {
14
+ name;
15
+ className;
16
+ hookName;
17
+ #commonSpecifier;
18
+ constructor(sys, name) {
19
+ this.name = name;
20
+ this.className = capitalize(name);
21
+ this.hookName = `use${this.className}`;
22
+ this.#commonSpecifier = `@${sys.type}s/${sys.name}/common`;
23
+ }
24
+ static nameOf(raw) {
25
+ const name = lowerlize(raw.replace(/^use(?=[A-Z])/, ""));
26
+ return /^[a-z][A-Za-z0-9]*$/.test(name) ? name : null;
27
+ }
28
+ static async build(sys, raw) {
29
+ const diagnostics = [];
30
+ const name = raw ? InteractionScaffold.nameOf(raw) : null;
31
+ if (!name) {
32
+ diagnostics.push({
33
+ severity: "error",
34
+ code: "create-interaction-name-invalid",
35
+ input: "interaction",
36
+ message: `Interaction name "${raw ?? ""}" must be camelCase (boardKeys), optionally prefixed with use.`
37
+ });
38
+ return { diagnostics, files: [] };
39
+ }
40
+ const scaffold = new InteractionScaffold(sys, name);
41
+ const files = scaffold.files;
42
+ const taken = (await Promise.all(scaffold.claimedPaths.map(async (path) => await sys.exists(path) ? `${sys.type}s/${sys.name}/${path}` : null))).filter((path) => !!path);
43
+ if (taken.length)
44
+ diagnostics.push({
45
+ severity: "error",
46
+ code: "create-interaction-exists",
47
+ input: "interaction",
48
+ message: `${taken.join(", ")} already exists; pick another interaction name or extend the existing files.`
49
+ });
50
+ return { diagnostics, files: taken.length ? [] : files };
51
+ }
52
+ get claimedPaths() {
53
+ const { name, hookName } = this;
54
+ return [
55
+ `common/${name}.ts`,
56
+ `common/${name}.tsx`,
57
+ `common/${name}.test.ts`,
58
+ `webkit/${hookName}.tsx`,
59
+ `webkit/${hookName}.ts`
60
+ ];
61
+ }
62
+ get files() {
63
+ return [
64
+ {
65
+ path: `common/${this.name}.ts`,
66
+ content: this.logicSource,
67
+ action: "create",
68
+ reason: "Pure interaction logic."
69
+ },
70
+ {
71
+ path: `common/${this.name}.test.ts`,
72
+ content: this.testSource,
73
+ action: "create",
74
+ reason: "Test of the pure interaction logic."
75
+ },
76
+ { path: `webkit/${this.hookName}.tsx`, content: this.hookSource, action: "create", reason: "Client hook." }
77
+ ];
78
+ }
79
+ get logicSource() {
80
+ return [
81
+ `export class ${this.className} {`,
82
+ " static next<State extends object>(state: State, input: Partial<State>) {",
83
+ " return { ...state, ...input };",
84
+ " }",
85
+ "}",
86
+ ""
87
+ ].join(`
88
+ `);
89
+ }
90
+ get testSource() {
91
+ return [
92
+ 'import { describe, expect, it } from "bun:test";',
93
+ `import { ${this.className} } from "./${this.name}";`,
94
+ "",
95
+ `describe(${JSON.stringify(this.className)}, () => {`,
96
+ ' it("applies an input over the state it is handed", () => {',
97
+ ` expect(${this.className}.next({ idx: 0, isOpen: false }, { idx: 1 })).toEqual({ idx: 1, isOpen: false });`,
98
+ " });",
99
+ "});",
100
+ ""
101
+ ].join(`
102
+ `);
103
+ }
104
+ get hookSource() {
105
+ return [
106
+ '"use client";',
107
+ `import { ${this.className} } from "${this.#commonSpecifier}";`,
108
+ "",
109
+ `export const ${this.hookName} = <State extends object>(state: State, commit: (next: State) => void) => {`,
110
+ " const change = async (input: Partial<State>) => {",
111
+ ` commit(${this.className}.next(state, input));`,
112
+ " };",
113
+ " return { change };",
114
+ "};",
115
+ ""
116
+ ].join(`
117
+ `);
118
+ }
119
+ }
9
120
 
10
121
  // pkgs/@akanjs/devkit/workflow/utils.ts
11
122
  var jsonText = (value, { trailingNewline = true } = {}) => `${JSON.stringify(value, null, 2)}${trailingNewline ? `
@@ -114,8 +225,10 @@ var planInputString = (plan, key) => {
114
225
  var workflowPathsForPlan = (plan) => {
115
226
  const app = planInputString(plan, "app");
116
227
  const module = planInputString(plan, "module");
117
- const moduleClass = module ? capitalize(module) : "<Module>";
118
- return plan.predictedChanges.map((change) => change.target.replace(/^\*\//, app ? `apps/${app}/` : "").replaceAll("<module>", module || "<module>").replaceAll("<Module>", moduleClass));
228
+ const moduleClass = module ? capitalize2(module) : "<Module>";
229
+ const rawInteraction = planInputString(plan, "interaction");
230
+ const interaction = rawInteraction ? InteractionScaffold.nameOf(rawInteraction) ?? rawInteraction : null;
231
+ return plan.predictedChanges.map((change) => change.target.replace(/^\*\//, app ? `apps/${app}/` : "").replaceAll("<module>", module || "<module>").replaceAll("<Module>", moduleClass).replaceAll("<interaction>", interaction || "<interaction>").replaceAll("<Interaction>", interaction ? capitalize2(interaction) : "<Interaction>"));
119
232
  };
120
233
  var workflowRunsDir = ".akan/workflows/runs";
121
234
  var createWorkflowRunId = (prefix = "run") => `${prefix}-${new Date().toISOString().replace(/[-:.TZ]/g, "").slice(0, 14)}-${Math.random().toString(36).slice(2, 8)}`;
@@ -386,7 +499,7 @@ var createRepairReport = ({
386
499
  ...syncedAt ? { syncedAt } : {}
387
500
  });
388
501
  // pkgs/@akanjs/devkit/workflow/executor.ts
389
- import { capitalize as capitalize2 } from "akanjs/common";
502
+ import { capitalize as capitalize3 } from "akanjs/common";
390
503
  import ts4 from "typescript";
391
504
 
392
505
  // pkgs/@akanjs/devkit/workflow/moduleIndex.ts
@@ -395,7 +508,7 @@ import path from "path";
395
508
  import ts3 from "typescript";
396
509
 
397
510
  // pkgs/@akanjs/devkit/workflow/source.ts
398
- import { lowerlize } from "akanjs/common";
511
+ import { lowerlize as lowerlize2 } from "akanjs/common";
399
512
  import ts2 from "typescript";
400
513
 
401
514
  // pkgs/@akanjs/devkit/workflow/sourceAst.ts
@@ -459,6 +572,7 @@ var moduleSourcePaths = (moduleName) => {
459
572
  abstract: `lib/${moduleName}/${moduleName}.abstract.md`,
460
573
  constant: `lib/${moduleName}/${moduleName}.constant.ts`,
461
574
  dictionary: `lib/${moduleName}/${moduleName}.dictionary.ts`,
575
+ document: `lib/${moduleName}/${moduleName}.document.ts`,
462
576
  service: `lib/${moduleName}/${moduleName}.service.ts`,
463
577
  signal: `lib/${moduleName}/${moduleName}.signal.ts`,
464
578
  store: `lib/${moduleName}/${moduleName}.store.ts`,
@@ -542,7 +656,7 @@ var koLabelForField = (fieldName) => {
542
656
  if (koLabels[fieldName])
543
657
  return koLabels[fieldName];
544
658
  const words = splitFieldWords(fieldName);
545
- const translated = words.map((word) => koLabels[word] ?? koLabels[lowerlize(word)] ?? null);
659
+ const translated = words.map((word) => koLabels[word] ?? koLabels[lowerlize2(word)] ?? null);
546
660
  return translated.every(Boolean) ? translated.join(" ") : null;
547
661
  };
548
662
  var bilingualLabelForField = (fieldName) => {
@@ -569,17 +683,48 @@ var normalizeFieldType = (typeName) => {
569
683
  };
570
684
  return normalizedTypes[typeName.toLowerCase()] ?? typeName;
571
685
  };
686
+ var importOrder = (a, b) => {
687
+ const [lowerA, lowerB] = [a.toLowerCase(), b.toLowerCase()];
688
+ if (lowerA !== lowerB)
689
+ return lowerA < lowerB ? -1 : 1;
690
+ return a < b ? -1 : a > b ? 1 : 0;
691
+ };
572
692
  var ensureNamedImport = (content, moduleSpecifier, name) => {
573
693
  const source = sourceFileFor("source.ts", content);
574
- const namedImport = findNamedImport(source, moduleSpecifier);
575
- if (namedImport) {
576
- if (namedImport.names.includes(name))
577
- return content;
578
- const nextNames = [...namedImport.names, name].sort();
579
- return spliceText(content, namedImport.namedBindingsStart, namedImport.namedBindingsEnd, `{ ${nextNames.join(", ")} }`);
580
- }
581
- return `import { ${name} } from "${moduleSpecifier}";
582
- ${content}`;
694
+ const namedImport = findNamedImport(source, moduleSpecifier, { valueOnly: true });
695
+ if (!namedImport)
696
+ return ensureImportDeclaration(content, moduleSpecifier, `{ ${name} }`);
697
+ if (namedImport.names.includes(name))
698
+ return content;
699
+ const nextElements = [...namedImport.elements, { name, text: name }].sort((a, b) => importOrder(a.name, b.name));
700
+ return spliceText(content, namedImport.namedBindingsStart, namedImport.namedBindingsEnd, `{ ${nextElements.map((element) => element.text).join(", ")} }`);
701
+ };
702
+ var ensureImportDeclaration = (content, moduleSpecifier, clause) => {
703
+ const line = `import ${clause} from "${moduleSpecifier}";`;
704
+ if (content.includes(line))
705
+ return content;
706
+ const source = sourceFileFor("source.ts", content);
707
+ const imports = source.statements.filter((statement) => ts2.isImportDeclaration(statement)).flatMap((statement) => ts2.isStringLiteral(statement.moduleSpecifier) ? [{ specifier: statement.moduleSpecifier.text, start: statement.getStart(source), end: statement.getEnd() }] : []);
708
+ const isRelative = (specifier) => specifier.startsWith(".");
709
+ const peers = imports.filter((entry) => isRelative(entry.specifier) === isRelative(moduleSpecifier));
710
+ const before = peers.find((entry) => importOrder(entry.specifier, moduleSpecifier) > 0);
711
+ if (before) {
712
+ const insertAt = lineStartAt(content, before.start);
713
+ return spliceText(content, insertAt, insertAt, `${line}
714
+ `);
715
+ }
716
+ const after = peers.at(-1) ?? (isRelative(moduleSpecifier) ? imports.at(-1) : undefined);
717
+ if (after) {
718
+ const insertAt = lineEndAt(content, after.end);
719
+ return spliceText(content, insertAt, insertAt, peers.length ? `${line}
720
+ ` : `
721
+ ${line}
722
+ `);
723
+ }
724
+ const insertAt = imports[0] ? lineStartAt(content, imports[0].start) : 0;
725
+ return spliceText(content, insertAt, insertAt, `${line}
726
+
727
+ `);
583
728
  };
584
729
  var ensureBaseImport = (content, name) => ensureNamedImport(content, "akanjs/base", name);
585
730
  var ensureBaseTypeImport = (content, typeName) => {
@@ -800,17 +945,18 @@ var dictionaryChainOrderValid = (chainMethods) => {
800
945
  }
801
946
  return true;
802
947
  };
803
- var findDictionaryModelObject = (source, moduleClassName) => {
948
+ var findDictionaryModelObject = (source, moduleClassName) => findDictionaryStageObject(source, "model", moduleClassName);
949
+ var findDictionaryStageObject = (source, stage, typeName) => {
804
950
  let locator = null;
805
951
  const visit = (node) => {
806
952
  if (locator)
807
953
  return;
808
- if (!ts2.isCallExpression(node) || callExpressionName(node) !== "model") {
954
+ if (!ts2.isCallExpression(node) || callExpressionName(node) !== stage) {
809
955
  ts2.forEachChild(node, visit);
810
956
  return;
811
957
  }
812
958
  const typeArgument = node.typeArguments?.[0];
813
- if (!typeArgument || typeArgument.getText(source) !== moduleClassName) {
959
+ if (!typeArgument || typeArgument.getText(source) !== typeName) {
814
960
  ts2.forEachChild(node, visit);
815
961
  return;
816
962
  }
@@ -852,17 +998,20 @@ var findLightProjectionArray = (source, moduleClassName) => {
852
998
  ts2.forEachChild(source, visit);
853
999
  return locator;
854
1000
  };
855
- var findNamedImport = (source, moduleSpecifier) => {
1001
+ var findNamedImport = (source, moduleSpecifier, { valueOnly = false } = {}) => {
856
1002
  for (const statement of source.statements) {
857
1003
  if (!ts2.isImportDeclaration(statement) || !ts2.isStringLiteral(statement.moduleSpecifier))
858
1004
  continue;
859
1005
  if (statement.moduleSpecifier.text !== moduleSpecifier)
860
1006
  continue;
1007
+ if (valueOnly && statement.importClause?.isTypeOnly)
1008
+ continue;
861
1009
  const namedBindings = statement.importClause?.namedBindings;
862
1010
  if (!namedBindings || !ts2.isNamedImports(namedBindings))
863
1011
  continue;
864
1012
  return {
865
1013
  names: namedBindings.elements.map((element) => element.name.text),
1014
+ elements: namedBindings.elements.map((element) => ({ name: element.name.text, text: element.getText(source) })),
866
1015
  namedBindingsStart: namedBindings.getStart(source),
867
1016
  namedBindingsEnd: namedBindings.getEnd()
868
1017
  };
@@ -1090,6 +1239,17 @@ var hasDictionaryModelField = (content, moduleClassName, fieldName) => {
1090
1239
  return false;
1091
1240
  return findDictionaryModelObject(source, moduleClassName)?.fields.some((field) => field.name === fieldName) ?? false;
1092
1241
  };
1242
+ var hasDictionaryEndpointEntry = (content, moduleClassName, entryName) => {
1243
+ const source = sourceFileFor("dictionary.ts", content);
1244
+ return findDictionaryStageObject(source, "endpoint", `${moduleClassName}Endpoint`)?.fields.some((field) => field.name === entryName) ?? false;
1245
+ };
1246
+ var insertDictionaryEndpointEntry = (content, moduleClassName, entryName, entryText) => {
1247
+ const source = sourceFileFor("dictionary.ts", content);
1248
+ const locator = findDictionaryStageObject(source, "endpoint", `${moduleClassName}Endpoint`);
1249
+ if (!locator)
1250
+ return null;
1251
+ return insertOrderedFieldLine(content, locator, entryName, entryText, { fieldIndent: " ", closingIndent: " " });
1252
+ };
1093
1253
  var ensureConstantTypeImport = (content, constantPath, typeName) => {
1094
1254
  if (new RegExp(`import type \\{[^}]*\\b${typeName}\\b[^}]*\\} from "${constantPath}";`).test(content))
1095
1255
  return content;
@@ -1144,6 +1304,14 @@ var hasClassMethod = (content, className, methodName) => {
1144
1304
  const node = findClassDeclaration(sourceFileFor("service.ts", content), className);
1145
1305
  return Boolean(node?.members.some((member) => ts2.isMethodDeclaration(member) && nodeName(member.name) === methodName));
1146
1306
  };
1307
+ var classMethodParameters = (content, className, methodName) => {
1308
+ const source = sourceFileFor("service.ts", content);
1309
+ const method = findClassDeclaration(source, className)?.members.find((member) => ts2.isMethodDeclaration(member) && nodeName(member.name) === methodName);
1310
+ return method?.parameters.map((parameter) => ({
1311
+ name: nodeName(parameter.name),
1312
+ optional: !!parameter.questionToken || !!parameter.initializer || !!parameter.dotDotDotToken
1313
+ })) ?? null;
1314
+ };
1147
1315
  var insertClassMethod = (content, className, methodBlock) => {
1148
1316
  const source = sourceFileFor("service.ts", content);
1149
1317
  const node = findClassDeclaration(source, className);
@@ -1228,6 +1396,33 @@ var insertSignalFactoryEntry = (content, className, entryName, entryLine, param)
1228
1396
  return null;
1229
1397
  return paramEdit === "unchanged" ? withEntry : spliceText(withEntry, paramEdit.start, paramEdit.end, paramEdit.text);
1230
1398
  };
1399
+ var appendTopLevelTestCases = (content, describeTitle, render) => {
1400
+ const bunImport = findNamedImport(sourceFileFor("test.ts", content), "bun:test", { valueOnly: true });
1401
+ const itName = !bunImport?.names.includes("it") && bunImport?.names.includes("test") ? "test" : "it";
1402
+ const imported = ensureNamedImport(content, "bun:test", itName);
1403
+ const source = sourceFileFor("test.ts", imported);
1404
+ const body = source.statements.flatMap((statement) => {
1405
+ if (!ts2.isExpressionStatement(statement) || !ts2.isCallExpression(statement.expression))
1406
+ return [];
1407
+ if (expressionName(statement.expression.expression) !== "describe")
1408
+ return [];
1409
+ const callback = factoryArrowOf(statement.expression);
1410
+ return callback && ts2.isBlock(callback.body) ? [callback.body] : [];
1411
+ })[0];
1412
+ if (!body) {
1413
+ const block = [`describe(${JSON.stringify(describeTitle)}, () => {`, ...render(itName, " "), "});", ""];
1414
+ return `${ensureNamedImport(imported, "bun:test", "describe").trimEnd()}
1415
+
1416
+ ${block.join(`
1417
+ `)}`;
1418
+ }
1419
+ const firstStatement = body.statements[0];
1420
+ const indent = firstStatement ? lineIndentAt(imported, firstStatement.getStart(source)) : `${lineIndentAt(imported, body.getStart(source))} `;
1421
+ const insertAt = lineStartAt(imported, body.getEnd() - 1);
1422
+ return spliceText(imported, insertAt, insertAt, `${render(itName, indent).join(`
1423
+ `)}
1424
+ `);
1425
+ };
1231
1426
 
1232
1427
  // pkgs/@akanjs/devkit/workflow/moduleIndex.ts
1233
1428
  var indexFileKinds = [
@@ -1891,10 +2086,10 @@ var addMutationActionSurfaceInspection = (plan) => {
1891
2086
  const moduleClassName = moduleComponentName(module);
1892
2087
  return surfaceReview(plan, {
1893
2088
  code: "add-mutation-action-surface-review",
1894
- target: `*/${moduleSourcePaths(module).store}`,
1895
- action: `Name the endpoint's guards and add its dictionary .endpoint() entry with a .desc(). After sync, fetch.${mutation} exists; write a store action only for a toast, an optimistic update, or a multi-field write, and put the control that calls it in ${moduleClassName}.Util.tsx.`,
1896
- message: `Workflow apply does not write store or UI code for ${module}.${mutation}; review whether a screen should call it.`,
1897
- reason: "Review action surface guidance before manually editing store or UI files."
2089
+ target: `*/${moduleSourcePaths(module).util}`,
2090
+ action: `Fill the ${moduleClassName} chain method (validate, mutate, return this) and replace its transition comment. After sync, call st.do.${mutation}(id) from the control in ${moduleClassName}.Util.tsx; a second write that must land with it is another with/after entry, never a second fetch in the store action.`,
2091
+ message: `Workflow apply does not write UI code for ${module}.${mutation}; review which screen calls it.`,
2092
+ reason: "Review action surface guidance before manually editing UI files."
1898
2093
  });
1899
2094
  };
1900
2095
  var addSliceViewSurfaceInspection = (plan) => {
@@ -1904,7 +2099,7 @@ var addSliceViewSurfaceInspection = (plan) => {
1904
2099
  return surfaceReview(plan, {
1905
2100
  code: "add-slice-view-surface-review",
1906
2101
  target: `*/${moduleSourcePaths(module).zone}`,
1907
- action: `Fill in the service query stub and add the dictionary .slice() entry. After sync, load fetch.init${moduleClassName}${capitalize2(slice)}() in the page and pass the result to a ${moduleClassName}.Zone as an init prop.`,
2102
+ action: `Fill in the service query stub and add the dictionary .slice() entry. After sync, load fetch.init${moduleClassName}${capitalize3(slice)}() in the page and pass the result to a ${moduleClassName}.Zone as an init prop.`,
1908
2103
  message: `Workflow apply does not write page or Zone code for ${module}.${slice}; review where the list should render.`,
1909
2104
  reason: "Review view surface guidance before manually editing Zone or page files."
1910
2105
  });
@@ -1917,7 +2112,8 @@ var createWorkflowStepRegistry = ({
1917
2112
  addField,
1918
2113
  addEnumField,
1919
2114
  addMutation,
1920
- addSlice
2115
+ addSlice,
2116
+ createInteraction
1921
2117
  }) => {
1922
2118
  const inspect = async () => {
1923
2119
  return;
@@ -1994,13 +2190,24 @@ var createWorkflowStepRegistry = ({
1994
2190
  })),
1995
2191
  [workflowStepKey("add-enum-field", "update-dictionary")]: inspect,
1996
2192
  [workflowStepKey("add-enum-field", "update-option")]: inspect,
1997
- [workflowStepKey("add-mutation", "update-service")]: async (_step, plan) => primitiveReportToWorkflowStepResult(await addMutation({
2193
+ [workflowStepKey("add-mutation", "update-document")]: async (_step, plan) => primitiveReportToWorkflowStepResult(await addMutation({
1998
2194
  app: workflowStringInput(plan.inputs.app),
1999
2195
  module: workflowStringInput(plan.inputs.module),
2000
- mutation: workflowStringInput(plan.inputs.mutation)
2196
+ mutation: workflowStringInput(plan.inputs.mutation),
2197
+ guards: workflowStringArrayInput(plan.inputs.guard),
2198
+ withCalls: workflowStringArrayInput(plan.inputs.with),
2199
+ afterCalls: workflowStringArrayInput(plan.inputs.after)
2001
2200
  })),
2201
+ [workflowStepKey("add-mutation", "update-service")]: inspect,
2002
2202
  [workflowStepKey("add-mutation", "update-signal")]: inspect,
2003
- [workflowStepKey("add-mutation", "update-action-surfaces")]: async (_step, plan) => addMutationActionSurfaceInspection(plan),
2203
+ [workflowStepKey("add-mutation", "update-store")]: inspect,
2204
+ [workflowStepKey("add-mutation", "update-dictionary")]: inspect,
2205
+ [workflowStepKey("add-mutation", "add-signal-test")]: inspect,
2206
+ [workflowStepKey("add-mutation", "connect-action-ui")]: async (_step, plan) => addMutationActionSurfaceInspection(plan),
2207
+ [workflowStepKey("create-interaction", "create-interaction")]: async (_step, plan) => primitiveReportToWorkflowStepResult(await createInteraction({
2208
+ app: workflowStringInput(plan.inputs.app),
2209
+ interaction: workflowStringInput(plan.inputs.interaction)
2210
+ })),
2004
2211
  [workflowStepKey("add-slice", "update-service-query")]: async (_step, plan) => primitiveReportToWorkflowStepResult(await addSlice({
2005
2212
  app: workflowStringInput(plan.inputs.app),
2006
2213
  module: workflowStringInput(plan.inputs.module),
@@ -2084,8 +2291,626 @@ class WorkflowExecutor {
2084
2291
  return report();
2085
2292
  }
2086
2293
  }
2294
+ // pkgs/@akanjs/devkit/workflow/guardCatalog.ts
2295
+ class GuardCatalog {
2296
+ static frameworkGuards = ["Public"];
2297
+ static #actingArgOf = new Map([
2298
+ ["User", { argName: "Self", param: "self", value: "self.id", serviceParam: "selfId" }],
2299
+ [
2300
+ "SignedIn",
2301
+ { argName: "CurrentUserId", param: "currentUserId", value: "currentUserId", serviceParam: "currentUserId" }
2302
+ ]
2303
+ ]);
2304
+ #guards;
2305
+ #internalArgs;
2306
+ reachedLibs;
2307
+ constructor(guards, internalArgs, reachedLibs) {
2308
+ this.#guards = guards;
2309
+ this.#internalArgs = internalArgs;
2310
+ this.reachedLibs = reachedLibs;
2311
+ }
2312
+ static async load(sys) {
2313
+ const reachedLibs = await GuardCatalog.#reachedLibs(sys);
2314
+ const scopes = [{ type: sys.type, name: sys.name }, ...reachedLibs.map((name) => ({ type: "lib", name }))];
2315
+ const exports = (await Promise.all(scopes.map((scope) => GuardCatalog.#srvkitExports(sys, scope)))).flat();
2316
+ const frameworkGuards = GuardCatalog.frameworkGuards.map((name) => ({ name, specifier: "akanjs/signal" }));
2317
+ return new GuardCatalog([...exports.filter((entry) => entry.kind === "Guard"), ...frameworkGuards], exports.filter((entry) => entry.kind === "InternalArg"), reachedLibs);
2318
+ }
2319
+ get names() {
2320
+ return [...new Set(this.#guards.map((guard) => guard.name))];
2321
+ }
2322
+ resolve(name) {
2323
+ const matches = this.#guards.filter((guard) => guard.name === name);
2324
+ const specifiers = [...new Set(matches.map((guard) => guard.specifier))];
2325
+ return { specifier: specifiers[0] ?? null, ambiguous: specifiers.length > 1 ? specifiers : null };
2326
+ }
2327
+ actingUserOf(guards) {
2328
+ for (const guard of guards) {
2329
+ const acting = GuardCatalog.#actingArgOf.get(guard);
2330
+ const specifier = acting ? this.#internalArgs.find((entry) => entry.name === acting.argName)?.specifier : undefined;
2331
+ if (acting && specifier)
2332
+ return { ...acting, specifier };
2333
+ }
2334
+ return null;
2335
+ }
2336
+ static async#reachedLibs(sys) {
2337
+ const workspaceLibs = await sys.workspace.getLibs();
2338
+ const depsOf = async (type, name) => {
2339
+ const jsonPath = `${type}s/${name}/akan.${type}.json`;
2340
+ if (!await sys.workspace.exists(jsonPath))
2341
+ return null;
2342
+ const { libDeps } = await sys.workspace.readJson(jsonPath);
2343
+ return Array.isArray(libDeps) ? libDeps.filter((lib) => workspaceLibs.includes(lib)) : [];
2344
+ };
2345
+ const direct = await depsOf(sys.type, sys.name);
2346
+ if (!direct)
2347
+ return workspaceLibs.filter((lib) => sys.type !== "lib" || lib !== sys.name);
2348
+ const reached = new Set;
2349
+ const queue = [...direct];
2350
+ while (queue.length) {
2351
+ const lib = queue.shift();
2352
+ if (!lib || reached.has(lib) || sys.type === "lib" && lib === sys.name)
2353
+ continue;
2354
+ reached.add(lib);
2355
+ queue.push(...await depsOf("lib", lib) ?? []);
2356
+ }
2357
+ return [...reached];
2358
+ }
2359
+ static async#srvkitExports(sys, scope) {
2360
+ const dir = `${scope.type}s/${scope.name}/srvkit`;
2361
+ const files = (await sys.workspace.readdir(dir)).filter((file) => /\.tsx?$/.test(file) && !/\.(test|spec)\.tsx?$/.test(file) && file !== "index.ts");
2362
+ const specifier = `@${scope.type}s/${scope.name}/srvkit`;
2363
+ const contents = await Promise.all(files.map((file) => sys.workspace.readFile(`${dir}/${file}`)));
2364
+ return contents.flatMap((content) => [...content.matchAll(/export class ([A-Z][A-Za-z0-9_]*)\s+implements\s+([^{]+)\{/g)].flatMap((match) => {
2365
+ const implemented = (match[2] ?? "").split(",").map((name) => name.replace(/<.*$/s, "").trim());
2366
+ const kind = implemented.includes("Guard") ? "Guard" : implemented.includes("InternalArg") ? "InternalArg" : null;
2367
+ return kind && match[1] ? [{ kind, name: match[1], specifier }] : [];
2368
+ }));
2369
+ }
2370
+ }
2371
+ // pkgs/@akanjs/devkit/workflow/mutationScaffold.ts
2372
+ import { lowerlize as lowerlize4 } from "akanjs/common";
2373
+
2374
+ // pkgs/@akanjs/devkit/workflow/mutationSource.ts
2375
+ import { lowerlize as lowerlize3 } from "akanjs/common";
2376
+ class MutationSource {
2377
+ static #irregularParticiples = new Map([
2378
+ ["admit", "admitted"],
2379
+ ["bind", "bound"],
2380
+ ["build", "built"],
2381
+ ["choose", "chosen"],
2382
+ ["commit", "committed"],
2383
+ ["control", "controlled"],
2384
+ ["cut", "cut"],
2385
+ ["find", "found"],
2386
+ ["freeze", "frozen"],
2387
+ ["get", "got"],
2388
+ ["give", "given"],
2389
+ ["hide", "hidden"],
2390
+ ["hold", "held"],
2391
+ ["keep", "kept"],
2392
+ ["lead", "led"],
2393
+ ["leave", "left"],
2394
+ ["lose", "lost"],
2395
+ ["make", "made"],
2396
+ ["omit", "omitted"],
2397
+ ["pay", "paid"],
2398
+ ["permit", "permitted"],
2399
+ ["put", "put"],
2400
+ ["read", "read"],
2401
+ ["run", "run"],
2402
+ ["sell", "sold"],
2403
+ ["send", "sent"],
2404
+ ["set", "set"],
2405
+ ["show", "shown"],
2406
+ ["shut", "shut"],
2407
+ ["split", "split"],
2408
+ ["submit", "submitted"],
2409
+ ["take", "taken"],
2410
+ ["transfer", "transferred"],
2411
+ ["win", "won"],
2412
+ ["write", "written"]
2413
+ ]);
2414
+ spec;
2415
+ modelClassName;
2416
+ model;
2417
+ idParam;
2418
+ chainMethod;
2419
+ constructor(spec) {
2420
+ this.spec = spec;
2421
+ this.modelClassName = moduleComponentName(spec.module);
2422
+ this.model = lowerlize3(this.modelClassName);
2423
+ this.idParam = `${this.model}Id`;
2424
+ this.chainMethod = MutationSource.chainMethodOf(spec.mutation, this.modelClassName);
2425
+ }
2426
+ static chainMethodOf(mutation, modelClassName) {
2427
+ const dropped = mutation.replace(modelClassName, "");
2428
+ return dropped && dropped !== mutation ? lowerlize3(dropped) : mutation;
2429
+ }
2430
+ static participleOf(verb) {
2431
+ const irregular = MutationSource.#irregularParticiples.get(verb);
2432
+ if (irregular)
2433
+ return irregular;
2434
+ if (verb.endsWith("e"))
2435
+ return `${verb}d`;
2436
+ if (/[^aeiou]y$/.test(verb))
2437
+ return `${verb.slice(0, -1)}ied`;
2438
+ if (/^[^aeiou]*[aeiou][^aeiouwxy]$/.test(verb))
2439
+ return `${verb}${verb.at(-1)}ed`;
2440
+ return `${verb}ed`;
2441
+ }
2442
+ get isPublic() {
2443
+ return this.spec.guards.includes("Public");
2444
+ }
2445
+ get #verb() {
2446
+ return this.chainMethod.replace(/[A-Z].*$/s, "");
2447
+ }
2448
+ get #noun() {
2449
+ return titleize(this.model).toLowerCase();
2450
+ }
2451
+ get chainMethodBlock() {
2452
+ return [
2453
+ ` // any \u2192 ${MutationSource.participleOf(this.#verb)}.`,
2454
+ ` ${this.chainMethod}() {`,
2455
+ " return this;",
2456
+ " }"
2457
+ ].join(`
2458
+ `);
2459
+ }
2460
+ get serviceMethod() {
2461
+ return this.chainMethod;
2462
+ }
2463
+ get serviceMethodBlock() {
2464
+ const { acting } = this.spec;
2465
+ const params = [`${this.idParam}: string`, ...acting ? [`${acting.serviceParam}: string`] : []];
2466
+ const load = `const ${this.model} = await this.get${this.modelClassName}(${this.idParam});`;
2467
+ const owned = acting ? [
2468
+ `// TODO: ${this.spec.guards.join(" and ")} admits any signed-in caller; refuse a ${acting.serviceParam} that may not ${this.#verb} this ${this.#noun}.`
2469
+ ] : [];
2470
+ const chained = `${this.model}.${this.chainMethod}().save()`;
2471
+ const head = ` async ${this.serviceMethod}(${params.join(", ")}) {`;
2472
+ if (!this.spec.withCalls.length && !this.spec.afterCalls.length)
2473
+ return [head, ` ${load}`, ...owned.map((line) => ` ${line}`), ` return await ${chained};`, " }"].join(`
2474
+ `);
2475
+ return [
2476
+ head,
2477
+ " return await this.transaction(async () => {",
2478
+ ` ${load}`,
2479
+ ...owned.map((line) => ` ${line}`),
2480
+ ` await ${chained};`,
2481
+ ...this.spec.withCalls.map((call) => ` await ${MutationSource.#callOf(call)};`),
2482
+ ...this.spec.afterCalls.map((call) => ` await this.afterCommit(() => ${MutationSource.#callOf(call)});`),
2483
+ ` return ${this.model};`,
2484
+ " });",
2485
+ " }"
2486
+ ].join(`
2487
+ `);
2488
+ }
2489
+ get signalEntry() {
2490
+ const options = this.isPublic ? `{ guards: [${this.spec.guards.join(", ")}], rateLimit: { calls: 20 } }` : `{ guards: [${this.spec.guards.join(", ")}] }`;
2491
+ const { acting } = this.spec;
2492
+ const execParams = [this.idParam, ...acting ? [acting.param] : []];
2493
+ const serviceArgs = [this.idParam, ...acting ? [acting.value] : []];
2494
+ return [
2495
+ `${this.spec.mutation}: mutation(cnst.${this.modelClassName}, ${options})`,
2496
+ ` .param("${this.idParam}", ID)`,
2497
+ ...acting ? [` .with(${acting.argName})`] : [],
2498
+ ` .exec(async function (${execParams.join(", ")}) {`,
2499
+ ` return await this.${this.model}Service.${this.serviceMethod}(${serviceArgs.join(", ")});`,
2500
+ " }),"
2501
+ ].join(`
2502
+ `);
2503
+ }
2504
+ get storeActionBlock() {
2505
+ return [
2506
+ ` async ${this.spec.mutation}(${this.idParam}: string) {`,
2507
+ ` this.set${this.modelClassName}(await fetch.${this.spec.mutation}(${this.idParam}));`,
2508
+ " }"
2509
+ ].join(`
2510
+ `);
2511
+ }
2512
+ dictionaryEntryOf(modelKo) {
2513
+ const label = bilingualLabelForField(this.spec.mutation);
2514
+ const modelLabel = { ...bilingualLabelForField(this.model), ...modelKo ? { ko: modelKo } : {} };
2515
+ const pair = (en, ko) => `[${JSON.stringify(en)}, ${JSON.stringify(ko)}]`;
2516
+ const idPair = pair(`${modelLabel.en} ID`, `${modelLabel.ko} ID`);
2517
+ return [
2518
+ `${this.spec.mutation}: fn(${pair(label.en, label.ko)})`,
2519
+ ` .desc(${pair(`API to ${label.en.toLowerCase()}`, `${label.ko} API`)})`,
2520
+ " .arg((t) => ({",
2521
+ ` ${this.idParam}: t(${idPair}).desc(${idPair}),`,
2522
+ " })),"
2523
+ ].join(`
2524
+ `);
2525
+ }
2526
+ get testTitles() {
2527
+ const guards = this.spec.guards.join(" and ");
2528
+ const participle = MutationSource.participleOf(this.#verb);
2529
+ return [
2530
+ `${this.spec.mutation} leaves the ${this.#noun} ${participle} for a caller ${guards} admits`,
2531
+ ...this.spec.guards.every((guard) => guard === "Public") ? [] : [`${this.spec.mutation} refuses a caller ${guards} turns away`],
2532
+ ...this.spec.acting ? [`${this.spec.mutation} refuses a signed-in caller who may not ${this.#verb} the ${this.#noun}`] : []
2533
+ ];
2534
+ }
2535
+ testCaseLines(itName, indent) {
2536
+ return this.testTitles.map((title) => `${indent}${itName}.todo(${JSON.stringify(title)});`);
2537
+ }
2538
+ get testFile() {
2539
+ return [
2540
+ 'import { describe, it } from "bun:test";',
2541
+ "",
2542
+ `describe(${JSON.stringify(`${this.modelClassName} Signal`)}, () => {`,
2543
+ ...this.testCaseLines("it", " "),
2544
+ "});",
2545
+ ""
2546
+ ].join(`
2547
+ `);
2548
+ }
2549
+ static #callOf(call) {
2550
+ const target = call.field ? `this.${call.field}` : "this";
2551
+ return `${target}.${call.method}(${call.args.join(", ")})`;
2552
+ }
2553
+ }
2554
+
2555
+ // pkgs/@akanjs/devkit/workflow/mutationScaffold.ts
2556
+ class MutationScaffold {
2557
+ static #documentMethods = new Set(["isModified", "refresh", "remove", "save", "set", "toJSON", "toObject"]);
2558
+ static #serviceMethods = new Set(["afterCommit", "logger", "onDestroy", "onInit", "transaction"]);
2559
+ static #callPattern = /^_?([a-z][A-Za-z0-9]*)\.([A-Za-z_$][\w$]*)$/;
2560
+ #sys;
2561
+ #catalog;
2562
+ #strict;
2563
+ #diagnostics = [];
2564
+ constructor(sys, catalog, { strict }) {
2565
+ this.#sys = sys;
2566
+ this.#catalog = catalog;
2567
+ this.#strict = strict;
2568
+ }
2569
+ static reservedNamesOf(modelClassName) {
2570
+ const model = lowerlize4(modelClassName);
2571
+ const prefixed = ["light", "create", "update", "remove", "view", "edit", "merge", "get", "load", "set", "reset"];
2572
+ return new Set([
2573
+ model,
2574
+ ...[...prefixed, "new", "submit", "invalidate"].map((prefix) => `${prefix}${modelClassName}`),
2575
+ `create${modelClassName}InForm`,
2576
+ `update${modelClassName}InForm`,
2577
+ `load${modelClassName}Many`,
2578
+ `get${modelClassName}View`,
2579
+ `get${modelClassName}Edit`,
2580
+ `add${modelClassName}Files`,
2581
+ `check${modelClassName}Submitable`,
2582
+ `writeOn${modelClassName}`,
2583
+ ...["load", "restore", "discard"].map((prefix) => `${prefix}${modelClassName}FormDraft`)
2584
+ ]);
2585
+ }
2586
+ static generates(modelClassName, name) {
2587
+ return MutationScaffold.reservedNamesOf(modelClassName).has(name) || new RegExp(`^(init${modelClassName}|get${modelClassName}Init|(set|add|sub|upload)\\w+On${modelClassName}$)`).test(name);
2588
+ }
2589
+ static inputDiagnostics(input) {
2590
+ const diagnostics = [];
2591
+ const error = (code, inputName, message) => diagnostics.push({ severity: "error", code, input: inputName, message });
2592
+ const { module, mutation } = input;
2593
+ if (mutation && !/^[a-z][A-Za-z0-9]*$/.test(mutation))
2594
+ error("add-mutation-name-invalid", "mutation", `Mutation name "${mutation}" must be a camelCase identifier.`);
2595
+ if (module && mutation) {
2596
+ const modelClassName = moduleComponentName(module);
2597
+ if (MutationScaffold.generates(modelClassName, mutation))
2598
+ error("add-mutation-name-reserved", "mutation", `"${mutation}" collides with a name Akan generates for ${modelClassName} (CRUD endpoints, store actions, form setters). Name the act, e.g. archive${modelClassName}.`);
2599
+ const chainMethod = MutationSource.chainMethodOf(mutation, modelClassName);
2600
+ if (MutationScaffold.#documentMethods.has(chainMethod))
2601
+ error("add-mutation-name-reserved", "mutation", `"${mutation}" drops to the document chain method ${chainMethod}(), which every document already has.`);
2602
+ else if (MutationScaffold.#serviceMethods.has(chainMethod))
2603
+ error("add-mutation-name-reserved", "mutation", `"${mutation}" drops to the service method ${chainMethod}(), which every service already has.`);
2604
+ }
2605
+ const guards = input.guards ?? [];
2606
+ if (!guards.length)
2607
+ error("add-mutation-guard-missing", "guard", "Name the guard(s) that admit a caller (guard=Admin, guard=Every,Person); add-mutation has no default guard.");
2608
+ for (const guard of guards) {
2609
+ if (guard === "None")
2610
+ error("add-mutation-guard-none", "guard", "None answers no caller, so the endpoint would ship dead; name the guard that admits the intended caller.");
2611
+ else if (!/^[A-Z][A-Za-z0-9]*$/.test(guard))
2612
+ error("add-mutation-guard-invalid", "guard", `Guard "${guard}" must be a guard class name.`);
2613
+ }
2614
+ for (const [inputName, calls] of [
2615
+ ["with", input.withCalls],
2616
+ ["after", input.afterCalls]
2617
+ ]) {
2618
+ for (const call of calls ?? [])
2619
+ if (!MutationScaffold.#callPattern.test(call))
2620
+ error("add-mutation-call-invalid", inputName, `"${call}" must name a service method as <serviceRef>.<method>, e.g. courtPc.pushPcCommand.`);
2621
+ }
2622
+ return diagnostics;
2623
+ }
2624
+ static async build(sys, input, { strict = true } = {}) {
2625
+ return await new MutationScaffold(sys, await GuardCatalog.load(sys), { strict }).#build(input);
2626
+ }
2627
+ async#build(input) {
2628
+ const files = [];
2629
+ const recommendations = [];
2630
+ this.#diagnostics.push(...MutationScaffold.inputDiagnostics(input));
2631
+ const { module, mutation } = input;
2632
+ const guards = [...new Set(input.guards ?? [])];
2633
+ const guardSpecifiers = this.#resolveGuards(guards);
2634
+ if (this.#hasGuardError())
2635
+ recommendations.push({
2636
+ code: "add-mutation-guard-choices",
2637
+ kind: "input-guidance",
2638
+ confidence: "high",
2639
+ message: `Guards this target reaches: ${this.#catalog.names.join(", ") || "none"}.`,
2640
+ action: "Re-plan with guard set to one or more of these names."
2641
+ });
2642
+ if (!module || !mutation || this.#hasError())
2643
+ return this.#result(files, recommendations);
2644
+ const paths = moduleSourcePaths(module);
2645
+ const sourcePaths = [paths.document, paths.service, paths.signal, paths.store, paths.dictionary];
2646
+ const present = await Promise.all(sourcePaths.map((path) => this.#sys.exists(path)));
2647
+ const missing = sourcePaths.filter((_, idx) => !present[idx]);
2648
+ if (missing.length) {
2649
+ this.#report("add-mutation-module-missing", `Module ${module} lacks ${missing.join(", ")}; add-mutation writes into an existing database module (create-module first).`, { input: "module" });
2650
+ return this.#result(files, recommendations);
2651
+ }
2652
+ const acting = this.#catalog.actingUserOf(guards);
2653
+ if (acting)
2654
+ recommendations.push({
2655
+ code: "add-mutation-ownership",
2656
+ kind: "manual-action",
2657
+ confidence: "high",
2658
+ message: `${guards.join(" and ")} admits any signed-in caller, so the service receives ${acting.serviceParam} and a TODO where it must refuse a caller who may not act on this ${module}.`,
2659
+ action: `Check ${acting.serviceParam} against the ${module} before the chain, or guard the mutation with a Can<Verb><Model> resource guard.`
2660
+ });
2661
+ const source = new MutationSource({
2662
+ module,
2663
+ mutation,
2664
+ guards,
2665
+ acting,
2666
+ withCalls: [],
2667
+ afterCalls: []
2668
+ });
2669
+ const [document, service, signal, store, dictionary] = await Promise.all(sourcePaths.map((path) => this.#sys.readFile(path)));
2670
+ await this.#checkNameFree(source, { service, signal, store, dictionary });
2671
+ const withCalls = await this.#resolveCalls(source, input.withCalls ?? [], "with", acting);
2672
+ const afterCalls = await this.#resolveCalls(source, input.afterCalls ?? [], "after", acting);
2673
+ if (this.#hasError())
2674
+ return this.#result(files, recommendations);
2675
+ const shaped = new MutationSource({ module, mutation, guards, acting, withCalls, afterCalls });
2676
+ const testPath = `lib/${module}/${module}.signal.test.ts`;
2677
+ const testExists = await this.#sys.exists(testPath);
2678
+ const edits = [
2679
+ [paths.document, this.#editDocument(document, shaped), "Document chain method was added.", "modify"],
2680
+ [
2681
+ paths.service,
2682
+ this.#editService(service, shaped, [...withCalls, ...afterCalls]),
2683
+ "Service mutation was added.",
2684
+ "modify"
2685
+ ],
2686
+ [paths.signal, this.#editSignal(signal, shaped, guardSpecifiers, acting), "Signal mutation was added.", "modify"],
2687
+ [paths.store, this.#editStore(store, shaped), "Store action was added.", "modify"],
2688
+ [paths.dictionary, this.#editDictionary(dictionary, shaped), "Dictionary endpoint entry was added.", "modify"],
2689
+ [
2690
+ testPath,
2691
+ testExists ? appendTopLevelTestCases(await this.#sys.readFile(testPath), `${shaped.modelClassName} Signal`, (itName, indent) => shaped.testCaseLines(itName, indent)) : shaped.testFile,
2692
+ "Signal test placeholders were added.",
2693
+ testExists ? "modify" : "create"
2694
+ ]
2695
+ ];
2696
+ for (const [path, content, reason, action] of edits) {
2697
+ if (content === null)
2698
+ continue;
2699
+ if (hasSourceParseErrors(content, path))
2700
+ this.#report("add-mutation-post-edit-parse-failed", `Edited ${path} did not parse; refusing to write source.`, {
2701
+ severity: "error"
2702
+ });
2703
+ files.push({ path, content, reason, action });
2704
+ }
2705
+ return this.#result(files, recommendations);
2706
+ }
2707
+ #result(files, recommendations) {
2708
+ const diagnostics = this.#diagnostics;
2709
+ return { diagnostics, recommendations, files: this.#hasError() ? [] : files };
2710
+ }
2711
+ #hasError() {
2712
+ return this.#diagnostics.some((diagnostic) => diagnostic.severity === "error");
2713
+ }
2714
+ #hasGuardError() {
2715
+ return this.#diagnostics.some((diagnostic) => diagnostic.code.startsWith("add-mutation-guard"));
2716
+ }
2717
+ #report(code, message, { input, severity } = {}) {
2718
+ this.#diagnostics.push({
2719
+ severity: severity ?? (this.#strict ? "error" : "warning"),
2720
+ code,
2721
+ message,
2722
+ input,
2723
+ failureScope: "source-change"
2724
+ });
2725
+ }
2726
+ #resolveGuards(guards) {
2727
+ const specifiers = new Map;
2728
+ for (const guard of guards) {
2729
+ if (guard === "None")
2730
+ continue;
2731
+ const { specifier, ambiguous } = this.#catalog.resolve(guard);
2732
+ if (ambiguous)
2733
+ this.#report("add-mutation-guard-ambiguous", `Guard "${guard}" is exported by ${ambiguous.join(" and ")}.`, {
2734
+ input: "guard",
2735
+ severity: "error"
2736
+ });
2737
+ else if (!specifier)
2738
+ this.#report("add-mutation-guard-unknown", `Guard "${guard}" is not exported by ${this.#sys.type}s/${this.#sys.name}/srvkit, the srvkit of a lib it reaches (${this.#catalog.reachedLibs.join(", ") || "none"}), or akanjs/signal.`, { input: "guard", severity: "error" });
2739
+ else
2740
+ specifiers.set(guard, specifier);
2741
+ }
2742
+ return specifiers;
2743
+ }
2744
+ async#checkNameFree(source, files) {
2745
+ const { mutation } = source.spec;
2746
+ const { modelClassName } = source;
2747
+ const taken = [
2748
+ hasClassMethod(files.service, `${modelClassName}Service`, source.serviceMethod) && `${modelClassName}Service.${source.serviceMethod}()`,
2749
+ ["Internal", "Slice", "Endpoint"].some((kind) => hasSignalFactoryEntry(files.signal, `${modelClassName}${kind}`, mutation)) && `${source.spec.module}.signal.ts`,
2750
+ hasClassMethod(files.store, `${modelClassName}Store`, mutation) && `${modelClassName}Store`,
2751
+ hasDictionaryEndpointEntry(files.dictionary, modelClassName, mutation) && `${source.spec.module}.dictionary.ts`,
2752
+ ...await this.#signalsDeclaring(mutation, source.spec.module)
2753
+ ].filter((place) => !!place);
2754
+ if (taken.length)
2755
+ this.#report("add-mutation-name-exists", `"${mutation}" already exists in ${taken.join(", ")}.`, {
2756
+ input: "mutation",
2757
+ severity: "error"
2758
+ });
2759
+ }
2760
+ async#signalsDeclaring(mutation, ownModule) {
2761
+ const pattern = new RegExp(`^\\s*${mutation}:\\s*(mutation|query|pubsub|message)\\(`, "m");
2762
+ const roots = [`${this.#sys.type}s/${this.#sys.name}`, ...this.#catalog.reachedLibs.map((lib) => `libs/${lib}`)];
2763
+ const hits = await Promise.all(roots.map(async (root) => {
2764
+ if (!await this.#sys.workspace.exists(`${root}/lib`))
2765
+ return [];
2766
+ const folders = (await this.#sys.workspace.readdir(`${root}/lib`)).filter((folder) => !folder.includes(".") && !folder.startsWith("__") && !(root === roots[0] && folder === ownModule));
2767
+ return await Promise.all(folders.map(async (folder) => {
2768
+ const name = folder.replace(/^_+/, "");
2769
+ const base = `${root}/lib/${folder}/${name}`;
2770
+ if (await this.#sys.workspace.exists(`${base}.document.ts`) && MutationScaffold.generates(moduleComponentName(name), mutation))
2771
+ return `${root}/lib/${folder} (generated for ${moduleComponentName(name)})`;
2772
+ if (!await this.#sys.workspace.exists(`${base}.signal.ts`))
2773
+ return null;
2774
+ return pattern.test(await this.#sys.workspace.readFile(`${base}.signal.ts`)) ? `${base}.signal.ts` : null;
2775
+ }));
2776
+ }));
2777
+ return hits.flat().filter((hit) => !!hit);
2778
+ }
2779
+ async#resolveCalls(source, calls, inputName, acting) {
2780
+ const resolved = [];
2781
+ for (const call of calls) {
2782
+ const [rawRef = "", method = ""] = call.split(".");
2783
+ const ref = rawRef.replace(/^_+/, "");
2784
+ const isOwn = ref === source.model;
2785
+ const service = await this.#serviceSourceOf(ref, isOwn);
2786
+ if (!service) {
2787
+ this.#report("add-mutation-call-service-missing", `${inputName}: no ${moduleComponentName(ref)}Service in ${this.#sys.name} or the libs it reaches.`, { input: inputName });
2788
+ continue;
2789
+ }
2790
+ const params = this.#parametersOf(service, ref, method);
2791
+ if (!params) {
2792
+ this.#report("add-mutation-call-method-missing", `${inputName}: ${service.className} has no ${method}().`, {
2793
+ input: inputName
2794
+ });
2795
+ continue;
2796
+ }
2797
+ const scope = new Map([
2798
+ [source.idParam, `${source.model}.id`],
2799
+ [source.model, source.model],
2800
+ ...isOwn ? [["id", `${source.model}.id`]] : [],
2801
+ ...acting ? [[acting.serviceParam, acting.serviceParam]] : []
2802
+ ]);
2803
+ const args = [];
2804
+ for (const param of params) {
2805
+ const value = param.name ? scope.get(param.name) : undefined;
2806
+ if (value) {
2807
+ args.push(value);
2808
+ continue;
2809
+ }
2810
+ if (!param.optional)
2811
+ this.#report("add-mutation-call-args-unresolved", `${inputName}: ${service.className}.${method}() takes "${param.name ?? "?"}", which add-mutation cannot supply. Name a method taking the ${source.model}, its id or the acting user, or call this one by hand after apply.`, { input: inputName, severity: "error" });
2812
+ break;
2813
+ }
2814
+ const field = isOwn ? null : `${ref}Service`;
2815
+ resolved.push({
2816
+ ref,
2817
+ method,
2818
+ field,
2819
+ args,
2820
+ injection: field ? { field, typeRef: service.typeRef } : null
2821
+ });
2822
+ }
2823
+ return resolved;
2824
+ }
2825
+ async#serviceSourceOf(ref, isOwn) {
2826
+ const className = `${moduleComponentName(ref)}Service`;
2827
+ const scopes = [
2828
+ { root: `${this.#sys.type}s/${this.#sys.name}`, typeRef: `srv.${className}` },
2829
+ ...isOwn ? [] : this.#catalog.reachedLibs.map((lib) => ({ root: `libs/${lib}`, typeRef: `srv.${lib}.${className}` }))
2830
+ ];
2831
+ for (const { root, typeRef } of scopes) {
2832
+ for (const folder of [ref, `_${ref}`]) {
2833
+ const path = `${root}/lib/${folder}/${ref}.service.ts`;
2834
+ if (await this.#sys.workspace.exists(path))
2835
+ return { className, typeRef, content: await this.#sys.workspace.readFile(path) };
2836
+ }
2837
+ }
2838
+ return null;
2839
+ }
2840
+ #parametersOf(service, ref, method) {
2841
+ const declared = classMethodParameters(service.content, service.className, method);
2842
+ if (declared)
2843
+ return declared;
2844
+ const modelClassName = moduleComponentName(ref);
2845
+ const generated = {
2846
+ [`get${modelClassName}`]: [{ name: "id", optional: false }],
2847
+ [`load${modelClassName}`]: [{ name: "id", optional: true }],
2848
+ [`load${modelClassName}Many`]: [{ name: "ids", optional: false }],
2849
+ [`create${modelClassName}`]: [{ name: "data", optional: false }],
2850
+ [`update${modelClassName}`]: [
2851
+ { name: "id", optional: false },
2852
+ { name: "data", optional: false }
2853
+ ],
2854
+ [`remove${modelClassName}`]: [{ name: "id", optional: false }]
2855
+ };
2856
+ return generated[method] ?? null;
2857
+ }
2858
+ #editDocument(content, source) {
2859
+ if (hasClassMethod(content, source.modelClassName, source.chainMethod)) {
2860
+ this.#report("add-mutation-chain-method-reused", `${source.modelClassName}.${source.chainMethod}() already exists; the service chains it as is.`, { severity: "warning" });
2861
+ return null;
2862
+ }
2863
+ return this.#required(insertClassMethod(content, source.modelClassName, source.chainMethodBlock), `class ${source.modelClassName} in the document`);
2864
+ }
2865
+ #editService(content, source, calls) {
2866
+ const className = `${source.modelClassName}Service`;
2867
+ let next = content;
2868
+ for (const { injection } of calls) {
2869
+ if (!next || !injection || hasSignalFactoryEntry(next, className, injection.field))
2870
+ continue;
2871
+ next = insertSignalFactoryEntry(next, className, injection.field, `${injection.field}: service<${injection.typeRef}>(),`, {
2872
+ mode: "destructure",
2873
+ name: "service"
2874
+ });
2875
+ if (next && !/\* as srv from "\.\.\/srv";/.test(next))
2876
+ next = ensureImportDeclaration(next, "../srv", "type * as srv");
2877
+ }
2878
+ next = next && insertClassMethod(next, className, source.serviceMethodBlock);
2879
+ return this.#required(next, `${className} and its serve() factory`);
2880
+ }
2881
+ #editSignal(content, source, guardSpecifiers, acting) {
2882
+ let next = insertSignalFactoryEntry(content, `${source.modelClassName}Endpoint`, source.spec.mutation, source.signalEntry, { mode: "destructure", name: "mutation" });
2883
+ if (!next)
2884
+ return this.#required(next, `${source.modelClassName}Endpoint and its endpoint() factory`);
2885
+ next = ensureNamedImport(next, "akanjs/base", "ID");
2886
+ if (!/\* as cnst from "\.\.\/cnst";/.test(next))
2887
+ next = ensureImportDeclaration(next, "../cnst", "* as cnst");
2888
+ for (const [guard, specifier] of guardSpecifiers)
2889
+ next = ensureNamedImport(next, specifier, guard);
2890
+ if (acting)
2891
+ next = ensureNamedImport(next, acting.specifier, acting.argName);
2892
+ return next;
2893
+ }
2894
+ #editStore(content, source) {
2895
+ const next = insertClassMethod(content, `${source.modelClassName}Store`, source.storeActionBlock);
2896
+ return this.#required(next && ensureNamedImport(next, "../useClient", "fetch"), `${source.modelClassName}Store`);
2897
+ }
2898
+ #editDictionary(content, source) {
2899
+ return this.#required(insertDictionaryEndpointEntry(content, source.modelClassName, source.spec.mutation, source.dictionaryEntryOf(MutationScaffold.#modelKoOf(content))), `.endpoint<${source.modelClassName}Endpoint>() in the dictionary`);
2900
+ }
2901
+ static #modelKoOf(dictionary) {
2902
+ return dictionary.match(/\.of\(\s*\(t\)\s*=>\s*t\(\s*\[\s*"[^"]*"\s*,\s*"([^"]+)"\s*\]/)?.[1];
2903
+ }
2904
+ #required(content, shape) {
2905
+ if (!content)
2906
+ this.#report("add-mutation-shape-unsupported", `Could not find ${shape}; refusing to write source.`, {
2907
+ severity: "error"
2908
+ });
2909
+ return content;
2910
+ }
2911
+ }
2087
2912
  // pkgs/@akanjs/devkit/workflow/plan.ts
2088
- import { capitalize as capitalize3 } from "akanjs/common";
2913
+ import { capitalize as capitalize4 } from "akanjs/common";
2089
2914
  var surfaceModes = new Set(["infer", "include", "skip"]);
2090
2915
  var parseStringList = (value) => {
2091
2916
  if (Array.isArray(value)) {
@@ -2228,7 +3053,7 @@ var createAddFieldRecommendations = (inputs) => {
2228
3053
  kind: "placement",
2229
3054
  target: paths.constant,
2230
3055
  confidence: "high",
2231
- message: `Insert ${field}: field(${normalizedType}) in ${capitalize3(module)}Input.`
3056
+ message: `Insert ${field}: field(${normalizedType}) in ${capitalize4(module)}Input.`
2232
3057
  },
2233
3058
  {
2234
3059
  code: "add-field-placement-dictionary",
@@ -2260,12 +3085,12 @@ var createAddFieldRecommendations = (inputs) => {
2260
3085
  kind: "placement",
2261
3086
  target: paths.constant,
2262
3087
  confidence: "high",
2263
- message: `Add ${field} to Light${capitalize3(module)} projection fields.`
3088
+ message: `Add ${field} to Light${capitalize4(module)} projection fields.`
2264
3089
  } : {
2265
3090
  code: "add-field-light-projection-choice",
2266
3091
  kind: "manual-action",
2267
3092
  target: paths.constant,
2268
- action: `Pass includeInLight=true when users should see ${field} in list/card data. Without it, the field can exist on ${capitalize3(module)}Input but stay absent from Light${capitalize3(module)} projections.`,
3093
+ action: `Pass includeInLight=true when users should see ${field} in list/card data. Without it, the field can exist on ${capitalize4(module)}Input but stay absent from Light${capitalize4(module)} projections.`,
2269
3094
  confidence: "medium",
2270
3095
  message: `${module}.${field} is not selected for list/card projection data.`
2271
3096
  },
@@ -2283,7 +3108,7 @@ var createAddFieldRecommendations = (inputs) => {
2283
3108
  code: "add-field-ui-manual-review",
2284
3109
  kind: "manual-action",
2285
3110
  target: paths.template,
2286
- action: `After apply, verify what users can see: Template form auto-edit only runs when a generated ${module}Form hook and Layout.Template field list are present. Unit/View cards are not auto-edited, so ${field} may be stored on ${capitalize3(module)} but not shown in list/card UI until you place it in the local card layout.`,
3111
+ action: `After apply, verify what users can see: Template form auto-edit only runs when a generated ${module}Form hook and Layout.Template field list are present. Unit/View cards are not auto-edited, so ${field} may be stored on ${capitalize4(module)} but not shown in list/card UI until you place it in the local card layout.`,
2287
3112
  confidence: "medium",
2288
3113
  message: `${app}:${module}.${field} may need UI review for user-visible Template, Unit, and View behavior.`
2289
3114
  },
@@ -2435,6 +3260,45 @@ var createWorkflowPlan = (spec, rawInputs) => {
2435
3260
  approval: workflowPlanApproval
2436
3261
  };
2437
3262
  };
3263
+ var planString = (inputs, name) => typeof inputs[name] === "string" ? inputs[name] : null;
3264
+ var planStrings = (inputs, name) => Array.isArray(inputs[name]) ? inputs[name] : null;
3265
+ var inspectWorkflowPlan = async (workspace, plan) => {
3266
+ if (plan.workflow !== "add-mutation" && plan.workflow !== "create-interaction")
3267
+ return plan;
3268
+ const app = planString(plan.inputs, "app");
3269
+ if (!app)
3270
+ return plan;
3271
+ const sys = await resolveWorkflowSys(workspace, app).catch(() => null);
3272
+ if (!sys)
3273
+ return {
3274
+ ...plan,
3275
+ diagnostics: [
3276
+ ...plan.diagnostics,
3277
+ {
3278
+ severity: "error",
3279
+ code: "workflow-target-missing",
3280
+ input: "app",
3281
+ message: `No app or library named ${app}.`
3282
+ }
3283
+ ]
3284
+ };
3285
+ const inspected = plan.workflow === "add-mutation" ? await MutationScaffold.build(sys, {
3286
+ module: planString(plan.inputs, "module"),
3287
+ mutation: planString(plan.inputs, "mutation"),
3288
+ guards: planStrings(plan.inputs, "guard"),
3289
+ withCalls: planStrings(plan.inputs, "with"),
3290
+ afterCalls: planStrings(plan.inputs, "after")
3291
+ }, { strict: false }) : { ...await InteractionScaffold.build(sys, planString(plan.inputs, "interaction")), recommendations: [] };
3292
+ const failedInputs = new Set(plan.diagnostics.filter((diagnostic) => diagnostic.severity === "error").map((diagnostic) => diagnostic.input));
3293
+ return {
3294
+ ...plan,
3295
+ diagnostics: [
3296
+ ...plan.diagnostics,
3297
+ ...inspected.diagnostics.filter((diagnostic) => !diagnostic.input || !failedInputs.has(diagnostic.input))
3298
+ ],
3299
+ recommendations: [...plan.recommendations, ...inspected.recommendations]
3300
+ };
3301
+ };
2438
3302
  // pkgs/@akanjs/devkit/workflow/render.ts
2439
3303
  var listOr = (items, render, empty = "- none") => items?.length ? items.map(render) : [empty];
2440
3304
  var renderDiagnostic = (diagnostic) => `- [${diagnostic.severity}] ${diagnostic.code}: ${diagnostic.message}`;
@@ -2448,7 +3312,11 @@ var renderRecommendation = (recommendation) => {
2448
3312
  var renderWorkflowList = (specs) => [
2449
3313
  "# Akan Workflows",
2450
3314
  "",
2451
- ...specs.flatMap((spec) => [`- \`${spec.name}\`: ${spec.description}`, ` - When: ${spec.whenToUse}`]),
3315
+ ...specs.flatMap((spec) => [
3316
+ `- \`${spec.name}\`: ${spec.description}`,
3317
+ ` - When: ${spec.whenToUse}`,
3318
+ ...spec.replacesRules?.length ? [` - Fixes: ${spec.replacesRules.map((rule) => `\`${rule}\``).join(", ")}`] : []
3319
+ ]),
2452
3320
  ""
2453
3321
  ].join(`
2454
3322
  `);
@@ -2460,6 +3328,12 @@ var renderWorkflowExplain = (spec) => [
2460
3328
  "## When To Use",
2461
3329
  spec.whenToUse,
2462
3330
  "",
3331
+ ...spec.replacesRules?.length ? [
3332
+ "## Replaces Rules",
3333
+ "This path is the fix when lint or the gate reports:",
3334
+ ...spec.replacesRules.map((rule) => `- \`${rule}\``),
3335
+ ""
3336
+ ] : [],
2463
3337
  "## Inputs",
2464
3338
  ...Object.entries(spec.inputs).map(([name, input]) => `- \`${name}\`${input.required ? " (required)" : ""}: ${input.description}${input.allowedValues ? ` Allowed: ${input.allowedValues.join(", ")}.` : ""}`),
2465
3339
  "",
@@ -2752,4 +3626,4 @@ for (const candidate of toolingRolloutCandidates) {
2752
3626
  if (isRestrictedCandidate(candidate))
2753
3627
  restrictedCandidates.set(candidate.packageName, candidate);
2754
3628
  }
2755
- export { 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, listWorkflowSpecs, getWorkflowSpec, compactWorkflowInputs, createWorkflowPlan, renderWorkflowList, renderWorkflowExplain, renderWorkflowPlan, renderWorkflowApply, renderWorkflowValidation, renderRepairReport, renderWorkflowRunArtifact, renderPrimitiveReport, toolingRolloutGate };
3629
+ 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, MutationScaffold, listWorkflowSpecs, getWorkflowSpec, compactWorkflowInputs, createWorkflowPlan, inspectWorkflowPlan, renderWorkflowList, renderWorkflowExplain, renderWorkflowPlan, renderWorkflowApply, renderWorkflowValidation, renderRepairReport, renderWorkflowRunArtifact, renderPrimitiveReport, toolingRolloutGate };