@akanjs/cli 3.2.0-rc.0 → 3.2.0-rc.10

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 (98) hide show
  1. package/.build-stamp +2 -1
  2. package/{CodeAgent-h6g8dg3a.js → CodeAgent-fk66n37w.js} +3 -3
  3. package/{CodeTui-n9gacepn.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 +6 -6
  9. package/{application.command-yb8v177e.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-et06ja22.js → cloud.command-ab704p0g.js} +24 -25
  13. package/cloud.script-4p4y0s7e.js +31 -0
  14. package/{code.command-7m67c7zc.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-evr3b35y.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/conventions/core.md +1 -1
  21. package/guidelines/conventions/rules/app.md +3 -0
  22. package/guidelines/conventions/rules/page.md +5 -0
  23. package/guidelines/errorCodes/errorCodes.instruction.md +140 -0
  24. package/guidelines/fieldRule/fieldRule.instruction.md +2 -1
  25. package/guidelines/mcpRule/mcpRule.instruction.md +28 -0
  26. package/guidelines/pageRule/pageRule.instruction.md +5 -0
  27. package/guidelines/runtimeRule/runtimeRule.instruction.md +5 -1
  28. package/guidelines/transportRule/transportRule.instruction.md +5 -0
  29. package/incrementalBuilder.proc.js +8 -7
  30. package/{index-vkzfk7qt.js → index-097bjwvm.js} +40 -30
  31. package/{index-93ewzmp6.js → index-23d8gw08.js} +165 -102
  32. package/{index-p6hjwt2d.js → index-41mfhgq0.js} +72 -26
  33. package/{index-ktb3wcqz.js → index-4k9nv4m3.js} +71 -81
  34. package/{index-ryrm5z2c.js → index-5jwx4bf2.js} +69 -33
  35. package/{index-5w9my9qe.js → index-6eptmk8z.js} +30 -20
  36. package/{index-d4n1wmrz.js → index-6fnrhpn1.js} +8 -4
  37. package/{index-kpdv34rq.js → index-6qtxs86x.js} +10 -7
  38. package/{index-ed6ea0qp.js → index-6z57w95f.js} +1 -1
  39. package/{index-drz9e84d.js → index-7ky4brfy.js} +2 -2
  40. package/{index-8g7tdsk4.js → index-849qvd7t.js} +58 -29
  41. package/{index-1q1cjn8s.js → index-9xh4zvw3.js} +94 -53
  42. package/{index-48d5qsj3.js → index-adj7qmz9.js} +23 -15
  43. package/{index-fjr4d6yd.js → index-apcr1qgk.js} +458 -304
  44. package/{index-8ts9774g.js → index-aybfcx58.js} +9 -4
  45. package/{index-3wjbhj2n.js → index-b3pr4ee6.js} +1 -1
  46. package/{index-tenw3mah.js → index-b4qq3rq0.js} +32 -7
  47. package/{index-thckcabc.js → index-bper31wr.js} +24 -6
  48. package/{index-jdamtr7e.js → index-bxkx0x03.js} +17 -10
  49. package/{index-0fb3cpbt.js → index-c3r23w24.js} +9 -7
  50. package/{index-8pb9yvp8.js → index-dfsa009c.js} +148 -31
  51. package/{index-zpv14wpy.js → index-dsg50er9.js} +3 -3
  52. package/{index-hqrkqxx2.js → index-e5f6czck.js} +46 -7
  53. package/{index-sy481q2x.js → index-frvjq1rd.js} +1 -1
  54. package/{index-abgh0jve.js → index-grt0e6kk.js} +1 -1
  55. package/{index-e3vmjtph.js → index-hf9nvwam.js} +7 -2
  56. package/{index-zxsygkda.js → index-hhagjhkh.js} +7 -7
  57. package/index-j4yvgfhr.js +70 -0
  58. package/{index-s2grpzef.js → index-k2r3hmbz.js} +6 -4
  59. package/{index-7y5yghjg.js → index-nd39rssn.js} +1162 -435
  60. package/{index-6wpaq392.js → index-p4htjyvk.js} +44 -5
  61. package/{index-aj3ehkcx.js → index-p54s83sz.js} +1 -1
  62. package/{index-7xdpww43.js → index-rdx8cyv2.js} +342 -134
  63. package/{index-sr5da35e.js → index-sq9d0jhj.js} +21 -18
  64. package/{index-eajbmk10.js → index-t4d0ckde.js} +2 -2
  65. package/{index-mqntfzv5.js → index-t8h09yjs.js} +7 -2
  66. package/index-va90m8nd.js +25 -0
  67. package/{index-rc5fvqj2.js → index-xfv2p7b5.js} +95 -58
  68. package/{index-w639tvkd.js → index-xgqz3kak.js} +29 -8
  69. package/{index-9tbgb4d8.js → index-xy70tcv4.js} +1 -1
  70. package/{index-mmym5xmb.js → index-z43wddce.js} +5 -3
  71. package/index.js +24 -23
  72. package/{library.command-1gp5qe3r.js → library.command-kc1zahcg.js} +5 -4
  73. package/{localRegistry.command-v3g21rex.js → localRegistry.command-bz2df40m.js} +19 -18
  74. package/{module.command-4xz9he6h.js → module.command-cchwzz9r.js} +12 -7
  75. package/{package.command-s7qpnn1g.js → package.command-qcjajpv8.js} +8 -7
  76. package/package.json +2 -2
  77. package/{page.command-fan34c49.js → page.command-1t86dx8a.js} +4 -3
  78. package/{pipeline.command-ph4fnn9w.js → pipeline.command-2xx9z3d0.js} +3 -2
  79. package/{primitive.command-3fqh8emf.js → primitive.command-mc0x8txr.js} +8 -7
  80. package/{projectTypecheck-vkb40hjc.js → projectTypecheck-tz497yx7.js} +2 -1
  81. package/{quality.command-ecj6exsh.js → quality.command-11rayf5c.js} +7 -6
  82. package/{repair.command-fe9jw719.js → repair.command-8w41vy78.js} +7 -6
  83. package/{scalar.command-cnvfhk0n.js → scalar.command-rvwh98ny.js} +7 -6
  84. package/skills/akan-debug/SKILL.md +7 -3
  85. package/skills/akan-err/SKILL.md +7 -0
  86. package/skills/akan-mcp/SKILL.md +7 -1
  87. package/skills/akan-scaffold/SKILL.md +3 -2
  88. package/skills/akan-transport/SKILL.md +2 -0
  89. package/skills/akan-validate/SKILL.md +1 -0
  90. package/{subspace.command-yxtt3v3e.js → subspace.command-0970n7kd.js} +9 -8
  91. package/{tunnel.command-ggj38mqf.js → tunnel.command-bcy0rtmh.js} +8 -7
  92. package/typecheck.proc.js +5 -2
  93. package/{verify.command-w9ttxkdz.js → verify.command-ynaztxr2.js} +18 -16
  94. package/{workflow.command-ss8devj0.js → workflow.command-yp9ajthb.js} +45 -16
  95. package/{workspace.command-rw1p0xeq.js → workspace.command-e4wfxm86.js} +39 -34
  96. package/TunnelShare-k3ja4w9x.js +0 -14
  97. package/cloud.script-s6rbrwer.js +0 -30
  98. package/context.runner-ms8v1rxy.js +0 -29
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  camelToKebabCase,
4
4
  runner
5
- } from "./index-93ewzmp6.js";
5
+ } from "./index-23d8gw08.js";
6
6
  import {
7
7
  FileSys2
8
8
  } from "./index-bns3wcpc.js";
@@ -21,7 +21,7 @@ import {
21
21
  SysExecutor,
22
22
  LibExecutor,
23
23
  PkgExecutor
24
- } from "./index-sr5da35e.js";
24
+ } from "./index-sq9d0jhj.js";
25
25
  import {
26
26
  countBlocking,
27
27
  formatStyleContract,
@@ -32,11 +32,11 @@ import {
32
32
  } from "./index-ygdbn9jn.js";
33
33
  import {
34
34
  MaintainabilityBaseline
35
- } from "./index-hqrkqxx2.js";
35
+ } from "./index-e5f6czck.js";
36
36
  import {
37
37
  createFactReader,
38
38
  createAst
39
- } from "./index-7y5yghjg.js";
39
+ } from "./index-nd39rssn.js";
40
40
  import {
41
41
  collectRecipeSources2,
42
42
  scanRecipes2
@@ -48,7 +48,7 @@ import {
48
48
  import {
49
49
  sysInputs,
50
50
  workflowSpecs
51
- } from "./index-eajbmk10.js";
51
+ } from "./index-t4d0ckde.js";
52
52
 
53
53
  // pkgs/@akanjs/cli/workspace/workspace.runner.ts
54
54
  import { mkdir, writeFile as writeFile2 } from "fs/promises";
@@ -62,20 +62,111 @@ var biomeVersion = "2.5.14";
62
62
  import { existsSync } from "fs";
63
63
  import { readFile, rm, writeFile } from "fs/promises";
64
64
  import path4 from "path";
65
- import ts12 from "typescript";
65
+ import ts13 from "typescript";
66
66
 
67
- // pkgs/@akanjs/devkit/componentSizeScanner.ts
67
+ // pkgs/@akanjs/devkit/bareErrorScanner.ts
68
68
  import ts from "typescript";
69
69
 
70
+ class BareErrorScanner {
71
+ static #builtins = new Set([
72
+ "Error",
73
+ "TypeError",
74
+ "RangeError",
75
+ "SyntaxError",
76
+ "ReferenceError",
77
+ "EvalError",
78
+ "URIError",
79
+ "AggregateError"
80
+ ]);
81
+ static #globals = new Set(["globalThis", "window", "self"]);
82
+ static #options = { noLib: true, noResolve: true, noEmit: true, types: [] };
83
+ lines(sourceFile) {
84
+ const declared = BareErrorScanner.#declaredNamesOf(sourceFile);
85
+ const shadows = [...BareErrorScanner.#builtins, ...BareErrorScanner.#globals].some((name) => declared.has(name));
86
+ if (!shadows)
87
+ return BareErrorScanner.#scan(sourceFile, () => true);
88
+ const rootName = sourceFile.fileName.endsWith(".tsx") ? "/scan.tsx" : "/scan.ts";
89
+ const scope = ts.createSourceFile(rootName, sourceFile.text, ts.ScriptTarget.Latest, true, rootName.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS);
90
+ const checker = ts.createProgram({
91
+ rootNames: [rootName],
92
+ options: BareErrorScanner.#options,
93
+ host: BareErrorScanner.#hostOf(scope)
94
+ }).getTypeChecker();
95
+ return BareErrorScanner.#scan(scope, (identifier) => !checker.getSymbolAtLocation(identifier)?.declarations?.some((declaration) => declaration.getSourceFile() === scope));
96
+ }
97
+ static #scan(sourceFile, isGlobal) {
98
+ const lines = [];
99
+ const visit = (node) => {
100
+ const constructed = ts.isNewExpression(node) || ts.isCallExpression(node) ? node.expression : null;
101
+ const extended = ts.isClassDeclaration(node) || ts.isClassExpression(node) ? node.heritageClauses?.find((clause) => clause.token === ts.SyntaxKind.ExtendsKeyword)?.types[0]?.expression : null;
102
+ const target = constructed ?? extended;
103
+ if (target && BareErrorScanner.#namesBuiltin(target, isGlobal))
104
+ lines.push(sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1);
105
+ ts.forEachChild(node, visit);
106
+ };
107
+ ts.forEachChild(sourceFile, visit);
108
+ return lines;
109
+ }
110
+ static #declaredNamesOf(sourceFile) {
111
+ const names = new Set;
112
+ const visit = (node) => {
113
+ if (ts.isIdentifier(node) && BareErrorScanner.#declares(node.parent, node))
114
+ names.add(node.text);
115
+ ts.forEachChild(node, visit);
116
+ };
117
+ ts.forEachChild(sourceFile, visit);
118
+ return names;
119
+ }
120
+ static #declares(parent, identifier) {
121
+ return (ts.isVariableDeclaration(parent) || ts.isParameter(parent) || ts.isBindingElement(parent) || ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(parent) || ts.isClassDeclaration(parent) || ts.isClassExpression(parent) || ts.isImportSpecifier(parent) || ts.isImportClause(parent) || ts.isNamespaceImport(parent) || ts.isImportEqualsDeclaration(parent) || ts.isEnumDeclaration(parent) || ts.isModuleDeclaration(parent)) && parent.name === identifier;
122
+ }
123
+ static #namesBuiltin(expression, isGlobal) {
124
+ const callee = BareErrorScanner.#unwrapped(expression);
125
+ if (ts.isIdentifier(callee))
126
+ return BareErrorScanner.#builtins.has(callee.text) && isGlobal(callee);
127
+ if (!ts.isPropertyAccessExpression(callee) || !BareErrorScanner.#builtins.has(callee.name.text))
128
+ return false;
129
+ const owner = BareErrorScanner.#unwrapped(callee.expression);
130
+ return ts.isIdentifier(owner) && BareErrorScanner.#globals.has(owner.text) && isGlobal(owner);
131
+ }
132
+ static #unwrapped(expression) {
133
+ let current = expression;
134
+ while (ts.isParenthesizedExpression(current) || ts.isAsExpression(current) || ts.isSatisfiesExpression(current) || ts.isNonNullExpression(current) || ts.isTypeAssertionExpression(current))
135
+ current = current.expression;
136
+ return current;
137
+ }
138
+ static #hostOf(scope) {
139
+ return {
140
+ getSourceFile: (fileName) => fileName === scope.fileName ? scope : undefined,
141
+ writeFile: () => {
142
+ return;
143
+ },
144
+ getDefaultLibFileName: () => "/lib.d.ts",
145
+ useCaseSensitiveFileNames: () => true,
146
+ getCanonicalFileName: (fileName) => fileName,
147
+ getCurrentDirectory: () => "/",
148
+ getNewLine: () => `
149
+ `,
150
+ fileExists: (fileName) => fileName === scope.fileName,
151
+ readFile: () => {
152
+ return;
153
+ }
154
+ };
155
+ }
156
+ }
157
+
158
+ // pkgs/@akanjs/devkit/componentSizeScanner.ts
159
+ import ts2 from "typescript";
160
+
70
161
  class ComponentSizeScanner {
71
162
  static #componentName = /^(?:[A-Z]|use[A-Z])[A-Za-z0-9]*$/;
72
163
  static componentsAndHooksOf(sourceFile) {
73
164
  return sourceFile.statements.flatMap((statement) => {
74
- if (ts.isFunctionDeclaration(statement))
165
+ if (ts2.isFunctionDeclaration(statement))
75
166
  return statement.name && statement.body && ComponentSizeScanner.#componentName.test(statement.name.text) ? [{ name: statement.name.text, node: statement }] : [];
76
- if (!ts.isVariableStatement(statement))
167
+ if (!ts2.isVariableStatement(statement))
77
168
  return [];
78
- return statement.declarationList.declarations.flatMap((declaration) => ts.isIdentifier(declaration.name) && ComponentSizeScanner.#componentName.test(declaration.name.text) && declaration.initializer && ComponentSizeScanner.#holdsFunction(declaration.initializer) ? [{ name: declaration.name.text, node: declaration }] : []);
169
+ return statement.declarationList.declarations.flatMap((declaration) => ts2.isIdentifier(declaration.name) && ComponentSizeScanner.#componentName.test(declaration.name.text) && declaration.initializer && ComponentSizeScanner.#holdsFunction(declaration.initializer) ? [{ name: declaration.name.text, node: declaration }] : []);
79
170
  });
80
171
  }
81
172
  measure(sourceFile) {
@@ -87,19 +178,19 @@ class ComponentSizeScanner {
87
178
  }
88
179
  static #holdsFunction(expression) {
89
180
  let current = expression;
90
- while (ts.isParenthesizedExpression(current) || ts.isAsExpression(current) || ts.isSatisfiesExpression(current))
181
+ while (ts2.isParenthesizedExpression(current) || ts2.isAsExpression(current) || ts2.isSatisfiesExpression(current))
91
182
  current = current.expression;
92
- if (ts.isArrowFunction(current) || ts.isFunctionExpression(current))
183
+ if (ts2.isArrowFunction(current) || ts2.isFunctionExpression(current))
93
184
  return true;
94
- return ts.isCallExpression(current) && current.arguments.some((arg) => ComponentSizeScanner.#holdsFunction(arg));
185
+ return ts2.isCallExpression(current) && current.arguments.some((arg) => ComponentSizeScanner.#holdsFunction(arg));
95
186
  }
96
187
  }
97
188
 
98
189
  // pkgs/@akanjs/devkit/componentWriteChainScanner.ts
99
- import ts4 from "typescript";
190
+ import ts5 from "typescript";
100
191
 
101
192
  // pkgs/@akanjs/devkit/storeAccessScanner.ts
102
- import ts2 from "typescript";
193
+ import ts3 from "typescript";
103
194
  class StoreAccessScanner {
104
195
  static #formSetter = /^(?:(?:set|add|sub|addOrSub|upload)[A-Z]\w*On|writeOn)[A-Z]\w*$/;
105
196
  #index;
@@ -112,10 +203,10 @@ class StoreAccessScanner {
112
203
  static localNamesOf(sourceFile, imported) {
113
204
  const names = new Set;
114
205
  for (const statement of sourceFile.statements) {
115
- if (!ts2.isImportDeclaration(statement) || statement.importClause?.isTypeOnly)
206
+ if (!ts3.isImportDeclaration(statement) || statement.importClause?.isTypeOnly)
116
207
  continue;
117
208
  const bindings = statement.importClause?.namedBindings;
118
- if (!bindings || !ts2.isNamedImports(bindings))
209
+ if (!bindings || !ts3.isNamedImports(bindings))
119
210
  continue;
120
211
  for (const element of bindings.elements)
121
212
  if (!element.isTypeOnly && (element.propertyName ?? element.name).text === imported)
@@ -130,9 +221,9 @@ class StoreAccessScanner {
130
221
  return ComponentSizeScanner.componentsAndHooksOf(sourceFile).map(({ name, node }) => {
131
222
  let accessCount = 0;
132
223
  const visit = (child) => {
133
- if (ts2.isPropertyAccessExpression(child) && ts2.isIdentifier(child.expression) && stNames.has(child.expression.text) && !this.#isFormSetter(child))
224
+ if (ts3.isPropertyAccessExpression(child) && ts3.isIdentifier(child.expression) && stNames.has(child.expression.text) && !this.#isFormSetter(child))
134
225
  accessCount += 1;
135
- ts2.forEachChild(child, visit);
226
+ ts3.forEachChild(child, visit);
136
227
  };
137
228
  visit(node);
138
229
  return {
@@ -144,12 +235,12 @@ class StoreAccessScanner {
144
235
  }
145
236
  #isFormSetter(access) {
146
237
  const action = access.parent;
147
- return access.name.text === "do" && ts2.isPropertyAccessExpression(action) && action.expression === access && StoreAccessScanner.#formSetter.test(action.name.text) && !this.#index.isWritingAction(action.name.text);
238
+ return access.name.text === "do" && ts3.isPropertyAccessExpression(action) && action.expression === access && StoreAccessScanner.#formSetter.test(action.name.text) && !this.#index.isWritingAction(action.name.text);
148
239
  }
149
240
  }
150
241
 
151
242
  // pkgs/@akanjs/devkit/writePath.ts
152
- import ts3 from "typescript";
243
+ import ts4 from "typescript";
153
244
 
154
245
  class WritePath {
155
246
  static #perElement = new Set([
@@ -171,15 +262,15 @@ class WritePath {
171
262
  this.#enters = enters;
172
263
  }
173
264
  along(node) {
174
- if (ts3.isFunctionLike(node) && !this.#enters(node))
265
+ if (ts4.isFunctionLike(node) && !this.#enters(node))
175
266
  return [];
176
267
  if (WritePath.isPerElementCallback(node))
177
268
  return this.#repeat(this.#children(node));
178
269
  if (WritePath.#isFlowStatement(node))
179
270
  return this.#busiestOf(this.#flowOf(node));
180
- if (ts3.isConditionalExpression(node))
271
+ if (ts4.isConditionalExpression(node))
181
272
  return [...this.along(node.condition), ...this.#busier(this.along(node.whenTrue), this.along(node.whenFalse))];
182
- const own = ts3.isCallExpression(node) && this.#matches(node) ? [node] : [];
273
+ const own = ts4.isCallExpression(node) && this.#matches(node) ? [node] : [];
183
274
  return [...own, ...this.#children(node)];
184
275
  }
185
276
  isRepeated(call) {
@@ -194,11 +285,11 @@ class WritePath {
194
285
  }
195
286
  static isPerElementCallback(node) {
196
287
  const call = node.parent;
197
- return (ts3.isArrowFunction(node) || ts3.isFunctionExpression(node)) && !!call && ts3.isCallExpression(call) && call.arguments.some((arg) => arg === node) && ts3.isPropertyAccessExpression(call.expression) && WritePath.#perElement.has(call.expression.name.text);
288
+ return (ts4.isArrowFunction(node) || ts4.isFunctionExpression(node)) && !!call && ts4.isCallExpression(call) && call.arguments.some((arg) => arg === node) && ts4.isPropertyAccessExpression(call.expression) && WritePath.#perElement.has(call.expression.name.text);
198
289
  }
199
290
  #children(node) {
200
291
  const children = [];
201
- ts3.forEachChild(node, (child) => {
292
+ ts4.forEachChild(node, (child) => {
202
293
  children.push(child);
203
294
  });
204
295
  return children.flatMap((child) => this.along(child));
@@ -209,25 +300,25 @@ class WritePath {
209
300
  return calls;
210
301
  }
211
302
  #flowOf(node) {
212
- if (ts3.isBlock(node))
303
+ if (ts4.isBlock(node))
213
304
  return this.#sequenceOf(node.statements);
214
- if (ts3.isReturnStatement(node) || ts3.isThrowStatement(node))
305
+ if (ts4.isReturnStatement(node) || ts4.isThrowStatement(node))
215
306
  return { through: null, exit: node.expression ? this.along(node.expression) : [], jump: null };
216
- if (ts3.isBreakStatement(node) || ts3.isContinueStatement(node))
307
+ if (ts4.isBreakStatement(node) || ts4.isContinueStatement(node))
217
308
  return { through: null, exit: null, jump: [] };
218
- if (ts3.isLabeledStatement(node))
309
+ if (ts4.isLabeledStatement(node))
219
310
  return this.#flowOf(node.statement);
220
- if (ts3.isIfStatement(node))
311
+ if (ts4.isIfStatement(node))
221
312
  return WritePath.#prefixed(this.along(node.expression), this.#merged(this.#flowOf(node.thenStatement), node.elseStatement ? this.#flowOf(node.elseStatement) : WritePath.#onward([])));
222
- if (ts3.isSwitchStatement(node))
313
+ if (ts4.isSwitchStatement(node))
223
314
  return WritePath.#prefixed(this.along(node.expression), this.#switchOf(node));
224
- if (ts3.isTryStatement(node))
315
+ if (ts4.isTryStatement(node))
225
316
  return this.#tryOf(node);
226
- if (ts3.isForOfStatement(node) || ts3.isForInStatement(node))
317
+ if (ts4.isForOfStatement(node) || ts4.isForInStatement(node))
227
318
  return this.#loopOf(this.along(node.expression), [], node.statement, true);
228
- if (ts3.isForStatement(node))
319
+ if (ts4.isForStatement(node))
229
320
  return this.#loopOf(node.initializer ? this.along(node.initializer) : [], [node.condition, node.incrementor].flatMap((part) => part ? this.along(part) : []), node.statement, WritePath.#walksItems(node.condition));
230
- if (ts3.isWhileStatement(node) || ts3.isDoStatement(node))
321
+ if (ts4.isWhileStatement(node) || ts4.isDoStatement(node))
231
322
  return this.#loopOf([], this.along(node.expression), node.statement, WritePath.#walksItems(node.expression));
232
323
  return WritePath.#onward(this.along(node));
233
324
  }
@@ -248,7 +339,7 @@ class WritePath {
248
339
  return { through, exit, jump };
249
340
  }
250
341
  #switchOf(node) {
251
- const hasDefault = node.caseBlock.clauses.some(ts3.isDefaultClause);
342
+ const hasDefault = node.caseBlock.clauses.some(ts4.isDefaultClause);
252
343
  let flow = { through: hasDefault ? null : [], exit: null, jump: null };
253
344
  let fallen = null;
254
345
  for (const clause of node.caseBlock.clauses) {
@@ -303,16 +394,16 @@ class WritePath {
303
394
  };
304
395
  }
305
396
  static #isFlowStatement(node) {
306
- return ts3.isBlock(node) || ts3.isIfStatement(node) || ts3.isSwitchStatement(node) || ts3.isTryStatement(node) || ts3.isLabeledStatement(node) || ts3.isReturnStatement(node) || ts3.isThrowStatement(node) || ts3.isBreakStatement(node) || ts3.isContinueStatement(node) || ts3.isIterationStatement(node, false);
397
+ return ts4.isBlock(node) || ts4.isIfStatement(node) || ts4.isSwitchStatement(node) || ts4.isTryStatement(node) || ts4.isLabeledStatement(node) || ts4.isReturnStatement(node) || ts4.isThrowStatement(node) || ts4.isBreakStatement(node) || ts4.isContinueStatement(node) || ts4.isIterationStatement(node, false);
307
398
  }
308
399
  static #walksItems(node) {
309
400
  if (!node)
310
401
  return false;
311
- if (ts3.isCallExpression(node))
402
+ if (ts4.isCallExpression(node))
312
403
  return true;
313
- if (ts3.isPropertyAccessExpression(node) && ["length", "size"].includes(node.name.text))
404
+ if (ts4.isPropertyAccessExpression(node) && ["length", "size"].includes(node.name.text))
314
405
  return true;
315
- return !!ts3.forEachChild(node, (child) => WritePath.#walksItems(child) || undefined);
406
+ return !!ts4.forEachChild(node, (child) => WritePath.#walksItems(child) || undefined);
316
407
  }
317
408
  #busier = (a, b) => this.countOf(b) > this.countOf(a) ? b : a;
318
409
  }
@@ -366,29 +457,29 @@ class ComponentWriteChainScanner {
366
457
  const visit = (node) => {
367
458
  if (ComponentWriteChainScanner.#isFunction(node) && node.body && !ComponentWriteChainScanner.#isInlineCallback(node))
368
459
  bodies.push(node.body);
369
- ts4.forEachChild(node, visit);
460
+ ts5.forEachChild(node, visit);
370
461
  };
371
462
  visit(component);
372
463
  return bodies;
373
464
  }
374
465
  static #isFunction(node) {
375
- return ts4.isArrowFunction(node) || ts4.isFunctionExpression(node) || ts4.isFunctionDeclaration(node) || ts4.isMethodDeclaration(node);
466
+ return ts5.isArrowFunction(node) || ts5.isFunctionExpression(node) || ts5.isFunctionDeclaration(node) || ts5.isMethodDeclaration(node);
376
467
  }
377
468
  static #isInlineCallback(fn) {
378
469
  const call = fn.parent;
379
- return !!call && ts4.isCallExpression(call) && call.arguments.some((arg) => arg === fn) && ts4.isPropertyAccessExpression(call.expression) && ComponentWriteChainScanner.#inlineCallers.has(call.expression.name.text);
470
+ return !!call && ts5.isCallExpression(call) && call.arguments.some((arg) => arg === fn) && ts5.isPropertyAccessExpression(call.expression) && ComponentWriteChainScanner.#inlineCallers.has(call.expression.name.text);
380
471
  }
381
472
  static #actionOf(callee, stNames) {
382
- if (!ts4.isPropertyAccessExpression(callee) || !ts4.isPropertyAccessExpression(callee.expression))
473
+ if (!ts5.isPropertyAccessExpression(callee) || !ts5.isPropertyAccessExpression(callee.expression))
383
474
  return null;
384
475
  const { expression: st, name } = callee.expression;
385
- return ts4.isIdentifier(st) && stNames.has(st.text) && name.text === "do" ? callee.name.text : null;
476
+ return ts5.isIdentifier(st) && stNames.has(st.text) && name.text === "do" ? callee.name.text : null;
386
477
  }
387
478
  }
388
479
 
389
480
  // pkgs/@akanjs/devkit/endpointReach.ts
390
481
  import path from "path";
391
- import ts5 from "typescript";
482
+ import ts6 from "typescript";
392
483
 
393
484
  class EndpointReach {
394
485
  static #requestBuilders = new Set(["endpoint", "slice"]);
@@ -397,9 +488,9 @@ class EndpointReach {
397
488
  const methodsByService = new Map;
398
489
  for (const { file, sourceFile } of serviceFiles) {
399
490
  const methods = methodsByService.get(EndpointReach.serviceOf(file)) ?? new Map;
400
- for (const cls of sourceFile.statements.filter(ts5.isClassDeclaration))
491
+ for (const cls of sourceFile.statements.filter(ts6.isClassDeclaration))
401
492
  for (const member of cls.members)
402
- if (ts5.isMethodDeclaration(member) && member.body && (ts5.isIdentifier(member.name) || ts5.isPrivateIdentifier(member.name)))
493
+ if (ts6.isMethodDeclaration(member) && member.body && (ts6.isIdentifier(member.name) || ts6.isPrivateIdentifier(member.name)))
403
494
  methods.set(member.name.text, member);
404
495
  methodsByService.set(EndpointReach.serviceOf(file), methods);
405
496
  }
@@ -412,9 +503,9 @@ class EndpointReach {
412
503
  pending.push([service, method]);
413
504
  };
414
505
  for (const { sourceFile } of signalFiles)
415
- for (const cls of sourceFile.statements.filter(ts5.isClassDeclaration)) {
506
+ for (const cls of sourceFile.statements.filter(ts6.isClassDeclaration)) {
416
507
  const base = cls.heritageClauses?.[0]?.types[0]?.expression;
417
- if (base && ts5.isCallExpression(base) && ts5.isIdentifier(base.expression) && EndpointReach.#requestBuilders.has(base.expression.text))
508
+ if (base && ts6.isCallExpression(base) && ts6.isIdentifier(base.expression) && EndpointReach.#requestBuilders.has(base.expression.text))
418
509
  EndpointReach.#serviceCallsIn(base, null).forEach(reach);
419
510
  }
420
511
  for (let next = pending.pop();next; next = pending.pop()) {
@@ -433,17 +524,17 @@ class EndpointReach {
433
524
  static #serviceCallsIn(node, ownService) {
434
525
  const calls = [];
435
526
  const visit = (child) => {
436
- if (ts5.isCallExpression(child) && ts5.isPropertyAccessExpression(child.expression)) {
527
+ if (ts6.isCallExpression(child) && ts6.isPropertyAccessExpression(child.expression)) {
437
528
  const { expression: owner, name } = child.expression;
438
- if (owner.kind === ts5.SyntaxKind.ThisKeyword && ownService)
529
+ if (owner.kind === ts6.SyntaxKind.ThisKeyword && ownService)
439
530
  calls.push([ownService, name.text]);
440
- else if (ts5.isPropertyAccessExpression(owner) && owner.expression.kind === ts5.SyntaxKind.ThisKeyword) {
531
+ else if (ts6.isPropertyAccessExpression(owner) && owner.expression.kind === ts6.SyntaxKind.ThisKeyword) {
441
532
  const field = owner.name.text;
442
533
  if (field.length > "Service".length && field.endsWith("Service"))
443
534
  calls.push([field.slice(0, -"Service".length), name.text]);
444
535
  }
445
536
  }
446
- ts5.forEachChild(child, visit);
537
+ ts6.forEachChild(child, visit);
447
538
  };
448
539
  visit(node);
449
540
  return calls;
@@ -452,7 +543,7 @@ class EndpointReach {
452
543
 
453
544
  // pkgs/@akanjs/devkit/maintainabilityLimits.ts
454
545
  import path3 from "path";
455
- import ts6 from "typescript";
546
+ import ts7 from "typescript";
456
547
 
457
548
  // pkgs/@akanjs/devkit/abstractDoc.ts
458
549
  import path2 from "path";
@@ -539,6 +630,14 @@ class MaintainabilityLimits {
539
630
  static packageFileMaxLines = 800;
540
631
  static functionMaxLines = 150;
541
632
  static classMaxMembers = 60;
633
+ static bareErrorRoots = new Map([
634
+ ["akanjs", ["server/", "service/", "signal/"]]
635
+ ]);
636
+ static repoOnlyRules = new Set(["akan.error.bare-error"]);
637
+ static holdsBareErrors(pkgName, pkgRelativePath) {
638
+ const roots = pkgName === null ? undefined : MaintainabilityLimits.bareErrorRoots.get(pkgName);
639
+ return (roots ?? []).some((root) => pkgRelativePath.startsWith(root));
640
+ }
542
641
  static fileKindOf(sysRelativePath) {
543
642
  const kinds = Object.keys(MaintainabilityLimits.#maxLinesByKind);
544
643
  const suffix = kinds.find((kind) => sysRelativePath.endsWith(kind));
@@ -555,7 +654,7 @@ class MaintainabilityLimits {
555
654
  static isReexportBarrel(file, content) {
556
655
  if (path3.posix.basename(file) !== "index.ts")
557
656
  return false;
558
- return ts6.createSourceFile(file, content, ts6.ScriptTarget.Latest, false, ts6.ScriptKind.TS).statements.every((statement) => ts6.isExportDeclaration(statement));
657
+ return ts7.createSourceFile(file, content, ts7.ScriptTarget.Latest, false, ts7.ScriptKind.TS).statements.every((statement) => ts7.isExportDeclaration(statement));
559
658
  }
560
659
  static lineCountOf(content) {
561
660
  return AbstractDoc.lineCountOf(content);
@@ -602,7 +701,9 @@ class MaintainabilityReport {
602
701
  "akan.component.store-access": MaintainabilityReport.#clientSplitFix,
603
702
  "akan.write.placement": "A server write leaves the browser through one store action, started by one module component. Move a `fetch.<mutation>` into a store action, and hand `ui/` and `webkit/` code the write as an `onX` prop or hook argument from the module's `Zone` or `Util`: they stay free of any one model, and an agent or another screen reaches the write through the store.",
604
703
  "akan.service.call-in-loop": "Load the set once (`load<Model>Many(ids)`, one filter query) or write it once (`create<Model>Many(rows)`, one batch method), then loop in memory: a call per item is a round trip per item, so the endpoint slows as its input grows.",
605
- "akan.baseline.growth": "Restore the entry from the default branch, then split the file or move the writes instead: `akan lint` lowers an entry as the code shrinks and never raises one."
704
+ "akan.error.bare-error": "Construct an `AkanError` subclass from `akanjs/base` with a code the caller can branch on, and a `statusCode` when it answers a request: an existing class whose code fits, or a new one beside the code that fails; a class extending a built-in Error extends `AkanError` instead. A failure another process reported travels as itself. The package's total is what is held, so moving a bare Error between files passes and `akan lint` rewrites the entries.",
705
+ "akan.baseline.growth": "Restore the entry from the default branch, then split the file or move the writes instead: `akan lint` lowers an entry as the code shrinks and never raises one.",
706
+ staleTotal: "Run `akan verify <package>`, which lowers the section, and commit `akan.baseline.json` in this change: a recorded total above the code is room for a new failure anywhere. A bare `akan verify` covers only uncommitted files."
606
707
  };
607
708
  static #labels = {
608
709
  "ui/": "ui/**",
@@ -617,7 +718,9 @@ class MaintainabilityReport {
617
718
  "akan.component.store-access": "component or hook reaching the store often",
618
719
  "akan.write.placement": "write sent outside a store action or module component",
619
720
  "akan.service.call-in-loop": "service call per item",
620
- "akan.baseline.growth": "baseline entry"
721
+ "akan.error.bare-error": "bare Error",
722
+ "akan.baseline.growth": "baseline entry",
723
+ staleTotal: "baseline total"
621
724
  };
622
725
  static #units = {
623
726
  "akan.size.file": "lines",
@@ -629,7 +732,8 @@ class MaintainabilityReport {
629
732
  "akan.store.root-write-chain": "writes",
630
733
  "akan.component.write-chain": "writes",
631
734
  "akan.write.placement": "writes",
632
- "akan.service.call-in-loop": "calls per item"
735
+ "akan.service.call-in-loop": "calls per item",
736
+ "akan.error.bare-error": "bare Errors"
633
737
  };
634
738
  static describe(sysPath, failures, commands = {}) {
635
739
  const groups = new Map;
@@ -665,11 +769,15 @@ class MaintainabilityReport {
665
769
  }));
666
770
  }
667
771
  static #problemOf(failure) {
772
+ if (failure.kind === "staleTotal")
773
+ return `records ${failure.recorded} ${MaintainabilityReport.#units[failure.rule]} in all, above the ${failure.count} the code holds`;
668
774
  if (failure.kind === "baselineGrowth") {
669
775
  const entry = `entry "${failure.key}" under ${failure.debtRule}`;
670
776
  const units = MaintainabilityReport.#units[failure.debtRule];
777
+ if (failure.key === MaintainabilityBaseline.totalKey)
778
+ return `${failure.debtRule} allows ${failure.count} ${units} in all, above the ${failure.committed ?? 0} ${failure.measured ? `the code at ${failure.reference} holds with no entry for its rule recorded there` : `at ${failure.reference}`}; the baseline may only shrink`;
671
779
  if (failure.measured)
672
- return failure.committed === undefined ? `${entry} is debt the code at ${failure.reference} does not hold, and with no baseline there the baseline may only shrink from that code` : `${entry} allows ${failure.count} ${units}, above the ${failure.committed} the code at ${failure.reference} holds with no baseline there; the baseline may only shrink`;
780
+ return failure.committed === undefined ? `${entry} is debt the code at ${failure.reference} does not hold, and with no entry for its rule recorded there the baseline may only shrink from that code` : `${entry} allows ${failure.count} ${units}, above the ${failure.committed} the code at ${failure.reference} holds with no entry for its rule recorded there; the baseline may only shrink`;
673
781
  return failure.committed === undefined ? `${entry} is not in the baseline at ${failure.reference}, which may only shrink` : `${entry} allows ${failure.count} ${units}, above the ${failure.committed} at ${failure.reference}; the baseline may only shrink`;
674
782
  }
675
783
  const grown = failure.recorded === undefined ? "" : `, more than the ${failure.recorded} recorded`;
@@ -684,6 +792,10 @@ class MaintainabilityReport {
684
792
  }
685
793
  if (failure.kind === "writePlacement")
686
794
  return `sends ${failure.writes.length} server write(s) from outside a store action or a module component: ${failure.writes.join(", ")}${grown}`;
795
+ if (failure.kind === "bareError") {
796
+ const plural = failure.lines.length === 1 ? "" : "s";
797
+ return `constructs or extends ${failure.lines.length} bare Error${plural}, on line${plural} ${failure.lines.join(", ")}${grown}, and the package's total grew`;
798
+ }
687
799
  if (failure.kind === "loopCall")
688
800
  return `service method ${failure.owner} calls once per item: ${failure.calls.join(", ")}${grown}`;
689
801
  if (failure.kind === "classSize")
@@ -698,6 +810,8 @@ class MaintainabilityReport {
698
810
  return /^use[A-Z]/.test(name) ? "hook" : "component";
699
811
  }
700
812
  static #fixKeyOf(sysPath, failure) {
813
+ if (failure.kind === "staleTotal")
814
+ return "staleTotal";
701
815
  if (failure.rule !== "akan.size.file")
702
816
  return failure.rule;
703
817
  if (sysPath.startsWith("pkgs/"))
@@ -710,13 +824,13 @@ class MaintainabilityReport {
710
824
  }
711
825
 
712
826
  // pkgs/@akanjs/devkit/serviceLoopCallScanner.ts
713
- import ts7 from "typescript";
827
+ import ts8 from "typescript";
714
828
  class ServiceLoopCallScanner {
715
829
  static #reachingField = /(?:Service|Model)$/;
716
830
  static #generatedQuery = /^_*(?:get|load|list|find|pick|exists|count|insight|create|update|remove|search)[A-Z]/;
717
831
  scan(sourceFile, answersCaller) {
718
- return sourceFile.statements.filter(ts7.isClassDeclaration).flatMap((cls) => {
719
- const methods = cls.members.filter((member) => ts7.isMethodDeclaration(member) && !!member.body && (ts7.isIdentifier(member.name) || ts7.isPrivateIdentifier(member.name)));
832
+ return sourceFile.statements.filter(ts8.isClassDeclaration).flatMap((cls) => {
833
+ const methods = cls.members.filter((member) => ts8.isMethodDeclaration(member) && !!member.body && (ts8.isIdentifier(member.name) || ts8.isPrivateIdentifier(member.name)));
720
834
  const declared = new Set(methods.map((method) => method.name.text));
721
835
  const reaching = ServiceLoopCallScanner.#reachingMethodsOf(methods, declared);
722
836
  const reaches = (call) => ServiceLoopCallScanner.#reaches(call, declared, reaching);
@@ -726,14 +840,14 @@ class ServiceLoopCallScanner {
726
840
  return [];
727
841
  const calls = [];
728
842
  const visit = (node, perItem) => {
729
- if (perItem && ts7.isCallExpression(node) && reaches(node) && !(perItem === "callback" && ServiceLoopCallScanner.#isBatchedLoad(node, declared, ownModel)))
843
+ if (perItem && ts8.isCallExpression(node) && reaches(node) && !(perItem === "callback" && ServiceLoopCallScanner.#isBatchedLoad(node, declared, ownModel)))
730
844
  calls.push(node);
731
- if (ts7.isForOfStatement(node) || ts7.isForInStatement(node)) {
845
+ if (ts8.isForOfStatement(node) || ts8.isForInStatement(node)) {
732
846
  visit(node.expression, perItem);
733
847
  visit(node.statement, "loop");
734
848
  return;
735
849
  }
736
- ts7.forEachChild(node, (child) => visit(child, perItem === "loop" || !WritePath.isPerElementCallback(child) ? perItem : "callback"));
850
+ ts8.forEachChild(node, (child) => visit(child, perItem === "loop" || !WritePath.isPerElementCallback(child) ? perItem : "callback"));
737
851
  };
738
852
  visit(method, false);
739
853
  const first = calls[0];
@@ -762,10 +876,10 @@ class ServiceLoopCallScanner {
762
876
  const visit = (node) => {
763
877
  if (found)
764
878
  return;
765
- if (ts7.isCallExpression(node) && ServiceLoopCallScanner.#reaches(node, declared, reaching))
879
+ if (ts8.isCallExpression(node) && ServiceLoopCallScanner.#reaches(node, declared, reaching))
766
880
  found = true;
767
881
  else
768
- ts7.forEachChild(node, visit);
882
+ ts8.forEachChild(node, visit);
769
883
  };
770
884
  visit(method);
771
885
  if (found) {
@@ -778,7 +892,7 @@ class ServiceLoopCallScanner {
778
892
  }
779
893
  static #isBatchedLoad(call, declared, ownModel) {
780
894
  const callee = call.expression;
781
- if (!ts7.isPropertyAccessExpression(callee))
895
+ if (!ts8.isPropertyAccessExpression(callee))
782
896
  return false;
783
897
  const model = ServiceLoopCallScanner.#loadedModelOf(callee, declared, ownModel);
784
898
  if (!model)
@@ -788,28 +902,28 @@ class ServiceLoopCallScanner {
788
902
  }
789
903
  static #loadedModelOf(callee, declared, ownModel) {
790
904
  const owner = callee.expression;
791
- if (owner.kind === ts7.SyntaxKind.ThisKeyword)
905
+ if (owner.kind === ts8.SyntaxKind.ThisKeyword)
792
906
  return declared.has(callee.name.text) ? null : ownModel;
793
- if (!ts7.isPropertyAccessExpression(owner) || owner.expression.kind !== ts7.SyntaxKind.ThisKeyword)
907
+ if (!ts8.isPropertyAccessExpression(owner) || owner.expression.kind !== ts8.SyntaxKind.ThisKeyword)
794
908
  return null;
795
909
  return owner.name.text.match(/^(\w+)Model$/)?.[1] ?? null;
796
910
  }
797
911
  static #reaches(call, declared, reaching) {
798
912
  const callee = call.expression;
799
- if (!ts7.isPropertyAccessExpression(callee))
913
+ if (!ts8.isPropertyAccessExpression(callee))
800
914
  return false;
801
915
  const owner = callee.expression;
802
- if (owner.kind === ts7.SyntaxKind.ThisKeyword) {
916
+ if (owner.kind === ts8.SyntaxKind.ThisKeyword) {
803
917
  const name = callee.name.text;
804
918
  return declared.has(name) ? reaching.has(name) : ServiceLoopCallScanner.#generatedQuery.test(name);
805
919
  }
806
- return ts7.isPropertyAccessExpression(owner) && owner.expression.kind === ts7.SyntaxKind.ThisKeyword && ServiceLoopCallScanner.#reachingField.test(owner.name.text);
920
+ return ts8.isPropertyAccessExpression(owner) && owner.expression.kind === ts8.SyntaxKind.ThisKeyword && ServiceLoopCallScanner.#reachingField.test(owner.name.text);
807
921
  }
808
922
  }
809
923
 
810
924
  // pkgs/@akanjs/devkit/signalMutationIndex.ts
811
925
  import { modelNames } from "akanjs/common";
812
- import ts8 from "typescript";
926
+ import ts9 from "typescript";
813
927
 
814
928
  class SignalMutationIndex {
815
929
  static #generatedArgCounts = [
@@ -819,7 +933,7 @@ class SignalMutationIndex {
819
933
  ["mergeModel", 2],
820
934
  ["addModelFiles", 2]
821
935
  ];
822
- static #reader = createFactReader(ts8, createAst(ts8));
936
+ static #reader = createFactReader(ts9, createAst(ts9));
823
937
  #shapesByOwner = new Map;
824
938
  constructor(sourceFiles) {
825
939
  for (const { file, sourceFile } of sourceFiles) {
@@ -869,7 +983,7 @@ class SignalMutationIndex {
869
983
 
870
984
  // pkgs/@akanjs/devkit/storeSource.ts
871
985
  import { modelNames as modelNames2 } from "akanjs/common";
872
- import ts9 from "typescript";
986
+ import ts10 from "typescript";
873
987
 
874
988
  class StoreSource {
875
989
  file;
@@ -894,7 +1008,7 @@ class StoreSource {
894
1008
  this.file = file;
895
1009
  this.#fetchNames = StoreSource.#fetchBindingsOf(sourceFile);
896
1010
  for (const statement of sourceFile.statements) {
897
- if (!ts9.isClassDeclaration(statement) || !statement.name)
1011
+ if (!ts10.isClassDeclaration(statement) || !statement.name)
898
1012
  continue;
899
1013
  const refName = StoreSource.#refNameOf(statement);
900
1014
  if (refName === undefined)
@@ -903,9 +1017,9 @@ class StoreSource {
903
1017
  this.stores.push({ name: store, refName });
904
1018
  const ownActions = new Set(refName ? StoreSource.generatedWritesOf(refName) : []);
905
1019
  for (const member of statement.members) {
906
- if (!ts9.isMethodDeclaration(member) || !member.body)
1020
+ if (!ts10.isMethodDeclaration(member) || !member.body)
907
1021
  continue;
908
- const isStatic = !!ts9.getModifiers(member)?.some(({ kind }) => kind === ts9.SyntaxKind.StaticKeyword);
1022
+ const isStatic = !!ts10.getModifiers(member)?.some(({ kind }) => kind === ts10.SyntaxKind.StaticKeyword);
909
1023
  const name = member.name.getText(sourceFile);
910
1024
  if (!isStatic)
911
1025
  ownActions.add(name);
@@ -919,65 +1033,65 @@ class StoreSource {
919
1033
  targetsIn(method) {
920
1034
  const targets = [];
921
1035
  const visit = (node) => {
922
- const target = ts9.isCallExpression(node) ? this.targetOf(method, node) : null;
1036
+ const target = ts10.isCallExpression(node) ? this.targetOf(method, node) : null;
923
1037
  if (target)
924
1038
  targets.push(target);
925
- ts9.forEachChild(node, visit);
1039
+ ts10.forEachChild(node, visit);
926
1040
  };
927
1041
  visit(method.body);
928
1042
  return targets;
929
1043
  }
930
1044
  targetOf(method, call) {
931
1045
  const callee = call.expression;
932
- if (!ts9.isPropertyAccessExpression(callee) && !ts9.isElementAccessExpression(callee))
1046
+ if (!ts10.isPropertyAccessExpression(callee) && !ts10.isElementAccessExpression(callee))
933
1047
  return null;
934
- const name = ts9.isPropertyAccessExpression(callee) ? callee.name.text : ts9.isStringLiteralLike(callee.argumentExpression) ? callee.argumentExpression.text : null;
1048
+ const name = ts10.isPropertyAccessExpression(callee) ? callee.name.text : ts10.isStringLiteralLike(callee.argumentExpression) ? callee.argumentExpression.text : null;
935
1049
  if (name === null)
936
1050
  return null;
937
1051
  const receiver = StoreSource.#unwrap(callee.expression);
938
- const isThis = receiver.kind === ts9.SyntaxKind.ThisKeyword;
1052
+ const isThis = receiver.kind === ts10.SyntaxKind.ThisKeyword;
939
1053
  if (isThis && method.isStatic)
940
1054
  return { kind: "static", store: method.store, name };
941
- if (!isThis && !ts9.isIdentifier(receiver))
1055
+ if (!isThis && !ts10.isIdentifier(receiver))
942
1056
  return null;
943
- if (ts9.isIdentifier(receiver) && this.#fetchNames.has(receiver.text))
1057
+ if (ts10.isIdentifier(receiver) && this.#fetchNames.has(receiver.text))
944
1058
  return { kind: "fetch", name };
945
- if (isThis || ts9.isIdentifier(receiver) && this.#rootAliasesByMethod.get(method)?.has(receiver.text))
1059
+ if (isThis || ts10.isIdentifier(receiver) && this.#rootAliasesByMethod.get(method)?.has(receiver.text))
946
1060
  return { kind: "action", name, isOwn: !!this.#ownActionsByStore.get(method.store)?.has(name) };
947
- return ts9.isIdentifier(receiver) ? { kind: "static", store: receiver.text, name } : null;
1061
+ return ts10.isIdentifier(receiver) ? { kind: "static", store: receiver.text, name } : null;
948
1062
  }
949
1063
  static #rootAliasesIn(method) {
950
1064
  const aliases = new Set;
951
1065
  const visit = (node) => {
952
- if (ts9.isParameter(node) && ts9.isIdentifier(node.name) && StoreSource.#isRootStoreType(node.type))
1066
+ if (ts10.isParameter(node) && ts10.isIdentifier(node.name) && StoreSource.#isRootStoreType(node.type))
953
1067
  aliases.add(node.name.text);
954
- if (ts9.isVariableDeclaration(node) && ts9.isIdentifier(node.name) && node.initializer && StoreSource.#unwrap(node.initializer).kind === ts9.SyntaxKind.ThisKeyword)
1068
+ if (ts10.isVariableDeclaration(node) && ts10.isIdentifier(node.name) && node.initializer && StoreSource.#unwrap(node.initializer).kind === ts10.SyntaxKind.ThisKeyword)
955
1069
  aliases.add(node.name.text);
956
- ts9.forEachChild(node, visit);
1070
+ ts10.forEachChild(node, visit);
957
1071
  };
958
1072
  visit(method);
959
1073
  return aliases;
960
1074
  }
961
1075
  static #isRootStoreType(type) {
962
- return !!type && ts9.isTypeReferenceNode(type) && ts9.isIdentifier(type.typeName) && type.typeName.text === "RootStore";
1076
+ return !!type && ts10.isTypeReferenceNode(type) && ts10.isIdentifier(type.typeName) && type.typeName.text === "RootStore";
963
1077
  }
964
1078
  static #unwrap(expression) {
965
1079
  let current = expression;
966
- while (ts9.isParenthesizedExpression(current) || ts9.isAsExpression(current) || ts9.isTypeAssertionExpression(current) || ts9.isSatisfiesExpression(current) || ts9.isNonNullExpression(current))
1080
+ while (ts10.isParenthesizedExpression(current) || ts10.isAsExpression(current) || ts10.isTypeAssertionExpression(current) || ts10.isSatisfiesExpression(current) || ts10.isNonNullExpression(current))
967
1081
  current = current.expression;
968
1082
  return current;
969
1083
  }
970
1084
  static #refNameOf(statement) {
971
1085
  for (const clause of statement.heritageClauses ?? []) {
972
- if (clause.token !== ts9.SyntaxKind.ExtendsKeyword)
1086
+ if (clause.token !== ts10.SyntaxKind.ExtendsKeyword)
973
1087
  continue;
974
1088
  for (const { expression } of clause.types) {
975
- if (!ts9.isCallExpression(expression) || !ts9.isIdentifier(expression.expression))
1089
+ if (!ts10.isCallExpression(expression) || !ts10.isIdentifier(expression.expression))
976
1090
  continue;
977
1091
  if (expression.expression.text !== "store")
978
1092
  continue;
979
1093
  const sig = expression.arguments[0];
980
- return sig && ts9.isPropertyAccessExpression(sig) ? sig.name.text : null;
1094
+ return sig && ts10.isPropertyAccessExpression(sig) ? sig.name.text : null;
981
1095
  }
982
1096
  }
983
1097
  return;
@@ -985,10 +1099,10 @@ class StoreSource {
985
1099
  static #fetchBindingsOf(sourceFile) {
986
1100
  const names = new Set;
987
1101
  for (const statement of sourceFile.statements) {
988
- if (!ts9.isImportDeclaration(statement) || statement.importClause?.isTypeOnly)
1102
+ if (!ts10.isImportDeclaration(statement) || statement.importClause?.isTypeOnly)
989
1103
  continue;
990
1104
  const bindings = statement.importClause?.namedBindings;
991
- if (!bindings || !ts9.isNamedImports(bindings))
1105
+ if (!bindings || !ts10.isNamedImports(bindings))
992
1106
  continue;
993
1107
  for (const element of bindings.elements)
994
1108
  if (!element.isTypeOnly && (element.propertyName ?? element.name).text === "fetch")
@@ -1036,7 +1150,7 @@ class StoreWriteScanner {
1036
1150
  }
1037
1151
 
1038
1152
  // pkgs/@akanjs/devkit/structureScanner.ts
1039
- import ts10 from "typescript";
1153
+ import ts11 from "typescript";
1040
1154
 
1041
1155
  class StructureScanner {
1042
1156
  measure(sourceFile) {
@@ -1044,14 +1158,14 @@ class StructureScanner {
1044
1158
  const classes = [];
1045
1159
  const lineOf = (pos) => sourceFile.getLineAndCharacterOfPosition(pos).line + 1;
1046
1160
  const visit = (node, owners) => {
1047
- if (ts10.isClassDeclaration(node) || ts10.isClassExpression(node)) {
1161
+ if (ts11.isClassDeclaration(node) || ts11.isClassExpression(node)) {
1048
1162
  const name = StructureScanner.#classNameOf(node);
1049
1163
  classes.push({
1050
1164
  name: [...owners, name].join("."),
1051
1165
  line: lineOf(node.getStart(sourceFile)),
1052
1166
  memberCount: StructureScanner.#memberCountOf(node)
1053
1167
  });
1054
- ts10.forEachChild(node, (child) => visit(child, [...owners, name]));
1168
+ ts11.forEachChild(node, (child) => visit(child, [...owners, name]));
1055
1169
  return;
1056
1170
  }
1057
1171
  if (StructureScanner.#isFunction(node)) {
@@ -1062,28 +1176,28 @@ class StructureScanner {
1062
1176
  line,
1063
1177
  lineCount: lineOf(node.getEnd()) - line + 1
1064
1178
  });
1065
- ts10.forEachChild(node, (child) => visit(child, [...owners, name]));
1179
+ ts11.forEachChild(node, (child) => visit(child, [...owners, name]));
1066
1180
  return;
1067
1181
  }
1068
- if (ts10.isObjectLiteralExpression(node)) {
1182
+ if (ts11.isObjectLiteralExpression(node)) {
1069
1183
  const name = StructureScanner.#boundNameOf(node);
1070
- ts10.forEachChild(node, (child) => visit(child, name === "<anonymous>" ? owners : [...owners, name]));
1184
+ ts11.forEachChild(node, (child) => visit(child, name === "<anonymous>" ? owners : [...owners, name]));
1071
1185
  return;
1072
1186
  }
1073
- ts10.forEachChild(node, (child) => visit(child, owners));
1187
+ ts11.forEachChild(node, (child) => visit(child, owners));
1074
1188
  };
1075
- ts10.forEachChild(sourceFile, (child) => visit(child, []));
1189
+ ts11.forEachChild(sourceFile, (child) => visit(child, []));
1076
1190
  return { functions, classes };
1077
1191
  }
1078
1192
  static #memberCountOf(node) {
1079
1193
  const methods = new Set;
1080
1194
  return node.members.filter((member) => {
1081
- if (ts10.isSemicolonClassElement(member) || ts10.isIndexSignatureDeclaration(member) || ts10.isClassStaticBlockDeclaration(member))
1195
+ if (ts11.isSemicolonClassElement(member) || ts11.isIndexSignatureDeclaration(member) || ts11.isClassStaticBlockDeclaration(member))
1082
1196
  return false;
1083
- if (!ts10.isMethodDeclaration(member) && !ts10.isConstructorDeclaration(member))
1197
+ if (!ts11.isMethodDeclaration(member) && !ts11.isConstructorDeclaration(member))
1084
1198
  return true;
1085
- const isStatic = ts10.getModifiers(member)?.some((modifier) => modifier.kind === ts10.SyntaxKind.StaticKeyword);
1086
- const key = `${isStatic ? "static " : ""}${ts10.isConstructorDeclaration(member) ? "constructor" : StructureScanner.#textOf(member.name)}`;
1199
+ const isStatic = ts11.getModifiers(member)?.some((modifier) => modifier.kind === ts11.SyntaxKind.StaticKeyword);
1200
+ const key = `${isStatic ? "static " : ""}${ts11.isConstructorDeclaration(member) ? "constructor" : StructureScanner.#textOf(member.name)}`;
1087
1201
  if (methods.has(key))
1088
1202
  return false;
1089
1203
  methods.add(key);
@@ -1091,64 +1205,64 @@ class StructureScanner {
1091
1205
  }).length;
1092
1206
  }
1093
1207
  static #isFunction(node) {
1094
- return (ts10.isFunctionDeclaration(node) || ts10.isMethodDeclaration(node) || ts10.isConstructorDeclaration(node) || ts10.isGetAccessorDeclaration(node) || ts10.isSetAccessorDeclaration(node) || ts10.isFunctionExpression(node) || ts10.isArrowFunction(node)) && node.body !== undefined;
1208
+ return (ts11.isFunctionDeclaration(node) || ts11.isMethodDeclaration(node) || ts11.isConstructorDeclaration(node) || ts11.isGetAccessorDeclaration(node) || ts11.isSetAccessorDeclaration(node) || ts11.isFunctionExpression(node) || ts11.isArrowFunction(node)) && node.body !== undefined;
1095
1209
  }
1096
1210
  static #functionNameOf(node) {
1097
- if (ts10.isConstructorDeclaration(node))
1211
+ if (ts11.isConstructorDeclaration(node))
1098
1212
  return "constructor";
1099
- if (ts10.isGetAccessorDeclaration(node))
1213
+ if (ts11.isGetAccessorDeclaration(node))
1100
1214
  return `get ${StructureScanner.#textOf(node.name)}`;
1101
- if (ts10.isSetAccessorDeclaration(node))
1215
+ if (ts11.isSetAccessorDeclaration(node))
1102
1216
  return `set ${StructureScanner.#textOf(node.name)}`;
1103
1217
  if (node.name)
1104
1218
  return StructureScanner.#textOf(node.name);
1105
- return ts10.isFunctionDeclaration(node) ? "default" : StructureScanner.#boundNameOf(node);
1219
+ return ts11.isFunctionDeclaration(node) ? "default" : StructureScanner.#boundNameOf(node);
1106
1220
  }
1107
1221
  static #classNameOf(node) {
1108
1222
  if (node.name)
1109
1223
  return node.name.text;
1110
- return ts10.isClassDeclaration(node) ? "default" : StructureScanner.#boundNameOf(node);
1224
+ return ts11.isClassDeclaration(node) ? "default" : StructureScanner.#boundNameOf(node);
1111
1225
  }
1112
1226
  static #boundNameOf(node) {
1113
1227
  let current = StructureScanner.#outerOf(node);
1114
1228
  let call = null;
1115
- while (ts10.isCallExpression(current.parent) || ts10.isNewExpression(current.parent)) {
1229
+ while (ts11.isCallExpression(current.parent) || ts11.isNewExpression(current.parent)) {
1116
1230
  const callee = current.parent.expression;
1117
1231
  if (current === callee)
1118
1232
  break;
1119
- call ??= `${ts10.isPropertyAccessExpression(callee) ? callee.name.text : ts10.isIdentifier(callee) ? callee.text : "call"}()`;
1233
+ call ??= `${ts11.isPropertyAccessExpression(callee) ? callee.name.text : ts11.isIdentifier(callee) ? callee.text : "call"}()`;
1120
1234
  current = StructureScanner.#outerOf(current.parent);
1121
1235
  }
1122
1236
  const { parent } = current;
1123
- if ((ts10.isVariableDeclaration(parent) || ts10.isPropertyAssignment(parent) || ts10.isPropertyDeclaration(parent) || ts10.isParameter(parent) || ts10.isBindingElement(parent)) && parent.name && !ts10.isObjectBindingPattern(parent.name) && !ts10.isArrayBindingPattern(parent.name))
1237
+ if ((ts11.isVariableDeclaration(parent) || ts11.isPropertyAssignment(parent) || ts11.isPropertyDeclaration(parent) || ts11.isParameter(parent) || ts11.isBindingElement(parent)) && parent.name && !ts11.isObjectBindingPattern(parent.name) && !ts11.isArrayBindingPattern(parent.name))
1124
1238
  return StructureScanner.#textOf(parent.name);
1125
- if (ts10.isBinaryExpression(parent) && parent.operatorToken.kind === ts10.SyntaxKind.EqualsToken)
1126
- return ts10.isPropertyAccessExpression(parent.left) ? parent.left.name.text : ts10.isIdentifier(parent.left) ? parent.left.text : "assigned";
1127
- if (ts10.isExportAssignment(parent))
1239
+ if (ts11.isBinaryExpression(parent) && parent.operatorToken.kind === ts11.SyntaxKind.EqualsToken)
1240
+ return ts11.isPropertyAccessExpression(parent.left) ? parent.left.name.text : ts11.isIdentifier(parent.left) ? parent.left.text : "assigned";
1241
+ if (ts11.isExportAssignment(parent))
1128
1242
  return "default";
1129
- if (ts10.isJsxExpression(parent))
1130
- return ts10.isJsxAttribute(parent.parent) ? ts10.isIdentifier(parent.parent.name) ? parent.parent.name.text : parent.parent.name.getText() : "children";
1243
+ if (ts11.isJsxExpression(parent))
1244
+ return ts11.isJsxAttribute(parent.parent) ? ts11.isIdentifier(parent.parent.name) ? parent.parent.name.text : parent.parent.name.getText() : "children";
1131
1245
  return call ?? "<anonymous>";
1132
1246
  }
1133
1247
  static #outerOf(node) {
1134
1248
  let current = node;
1135
- while (ts10.isParenthesizedExpression(current.parent) || ts10.isAsExpression(current.parent) || ts10.isSatisfiesExpression(current.parent) || ts10.isNonNullExpression(current.parent) || ts10.isTypeAssertionExpression(current.parent) || ts10.isPropertyAccessExpression(current.parent) && current.parent.expression === current || ts10.isCallExpression(current.parent) && current.parent.expression === current)
1249
+ while (ts11.isParenthesizedExpression(current.parent) || ts11.isAsExpression(current.parent) || ts11.isSatisfiesExpression(current.parent) || ts11.isNonNullExpression(current.parent) || ts11.isTypeAssertionExpression(current.parent) || ts11.isPropertyAccessExpression(current.parent) && current.parent.expression === current || ts11.isCallExpression(current.parent) && current.parent.expression === current)
1136
1250
  current = current.parent;
1137
1251
  return current;
1138
1252
  }
1139
1253
  static #textOf(name) {
1140
- if (ts10.isIdentifier(name) || ts10.isPrivateIdentifier(name) || ts10.isStringLiteral(name))
1254
+ if (ts11.isIdentifier(name) || ts11.isPrivateIdentifier(name) || ts11.isStringLiteral(name))
1141
1255
  return name.text;
1142
- if (ts10.isNumericLiteral(name) || ts10.isNoSubstitutionTemplateLiteral(name))
1256
+ if (ts11.isNumericLiteral(name) || ts11.isNoSubstitutionTemplateLiteral(name))
1143
1257
  return name.text;
1144
- if (ts10.isComputedPropertyName(name))
1258
+ if (ts11.isComputedPropertyName(name))
1145
1259
  return `[${name.expression.getText()}]`;
1146
1260
  return "<pattern>";
1147
1261
  }
1148
1262
  }
1149
1263
 
1150
1264
  // pkgs/@akanjs/devkit/writePlacementScanner.ts
1151
- import ts11 from "typescript";
1265
+ import ts12 from "typescript";
1152
1266
  class WritePlacementScanner {
1153
1267
  #index;
1154
1268
  constructor(index) {
@@ -1161,9 +1275,9 @@ class WritePlacementScanner {
1161
1275
  return null;
1162
1276
  const sites = [];
1163
1277
  const visit = (node) => {
1164
- if (ts11.isPropertyAccessExpression(node) && this.#isWrite(node, workspaceFile, fetchNames, stNames))
1278
+ if (ts12.isPropertyAccessExpression(node) && this.#isWrite(node, workspaceFile, fetchNames, stNames))
1165
1279
  sites.push(node);
1166
- ts11.forEachChild(node, visit);
1280
+ ts12.forEachChild(node, visit);
1167
1281
  };
1168
1282
  visit(sourceFile);
1169
1283
  const first = sites[0];
@@ -1176,9 +1290,9 @@ class WritePlacementScanner {
1176
1290
  }
1177
1291
  #isWrite(access, workspaceFile, fetchNames, stNames) {
1178
1292
  const owner = access.expression;
1179
- if (ts11.isIdentifier(owner) && fetchNames.has(owner.text))
1293
+ if (ts12.isIdentifier(owner) && fetchNames.has(owner.text))
1180
1294
  return this.#index.isMutation(workspaceFile, access.name.text);
1181
- return ts11.isPropertyAccessExpression(owner) && owner.name.text === "do" && ts11.isIdentifier(owner.expression) && stNames.has(owner.expression.text) && this.#index.isWritingAction(access.name.text);
1295
+ return ts12.isPropertyAccessExpression(owner) && owner.name.text === "do" && ts12.isIdentifier(owner.expression) && stNames.has(owner.expression.text) && this.#index.isWritingAction(access.name.text);
1182
1296
  }
1183
1297
  }
1184
1298
 
@@ -1250,6 +1364,7 @@ class MaintainabilityContract {
1250
1364
  "akan.component.store-access",
1251
1365
  "akan.write.placement",
1252
1366
  "akan.service.call-in-loop",
1367
+ "akan.error.bare-error",
1253
1368
  "akan.baseline.growth"
1254
1369
  ];
1255
1370
  static #measuredFiles = "{lib,ui,webkit,srvkit,common,plugin}/**/*.{ts,tsx,md}";
@@ -1293,16 +1408,30 @@ class MaintainabilityContract {
1293
1408
  const tightened = baseline.tightenedBy(violations);
1294
1409
  if (fix && existing !== null)
1295
1410
  await this.#tighten(baseline, tightened);
1296
- const failures = violations.filter((violation) => !baseline.allows(violation)).map((violation) => {
1297
- const recorded = baseline.recordedOf(violation);
1298
- return recorded === undefined ? violation : { ...violation, recorded };
1299
- });
1300
1411
  const working = fix ? tightened : baseline;
1412
+ const lines = (await this.#readBaseline() ?? "").split(/\r?\n/);
1413
+ const failures = [
1414
+ ...working.staleTotals(violations).map(({ rule, count, recorded }) => ({
1415
+ kind: "staleTotal",
1416
+ rule,
1417
+ key: MaintainabilityBaseline.totalKey,
1418
+ file: MaintainabilityBaseline.fileName,
1419
+ line: MaintainabilityContract.#lineOf(lines, rule, MaintainabilityBaseline.totalKey),
1420
+ count,
1421
+ recorded
1422
+ })),
1423
+ ...baseline.unallowed(violations).map((violation) => {
1424
+ const recorded = baseline.recordedOf(violation);
1425
+ return recorded === undefined ? violation : { ...violation, recorded };
1426
+ })
1427
+ ];
1301
1428
  const source = `${reference.label}:${this.sysPath}/${MaintainabilityBaseline.fileName}`;
1302
- const committed = reference.text !== null ? MaintainabilityBaseline.parse(reference.text, source, { lenient: true }) : working.isEmpty ? null : await this.#measuredAt(reference.ref);
1303
- if (committed === null)
1429
+ const recorded = reference.text !== null ? MaintainabilityBaseline.parse(reference.text, source, { lenient: true }) : null;
1430
+ const unrecorded = new Set(working.rulesOutside(recorded));
1431
+ const measured = unrecorded.size ? await this.#measuredAt(reference.ref) : null;
1432
+ if (recorded === null && measured === null)
1304
1433
  return failures;
1305
- const lines = (await this.#readBaseline() ?? "").split(/\r?\n/);
1434
+ const committed = (recorded ?? new MaintainabilityBaseline).withSectionsOf(measured, unrecorded);
1306
1435
  const growths = working.grownFrom(committed).map(({ rule, ...growth }) => ({
1307
1436
  kind: "baselineGrowth",
1308
1437
  rule: "akan.baseline.growth",
@@ -1310,7 +1439,7 @@ class MaintainabilityContract {
1310
1439
  line: MaintainabilityContract.#lineOf(lines, rule, growth.key),
1311
1440
  debtRule: rule,
1312
1441
  reference: reference.label,
1313
- ...reference.text === null ? { measured: true } : {},
1442
+ ...unrecorded.has(rule) ? { measured: true } : {},
1314
1443
  ...growth
1315
1444
  })).sort((a, b) => a.line - b.line);
1316
1445
  return [...growths, ...failures];
@@ -1332,14 +1461,25 @@ class MaintainabilityContract {
1332
1461
  }
1333
1462
  async#measurePackage() {
1334
1463
  const files = (await this.#packageFiles()).filter(MaintainabilityLimits.isPackageSource);
1464
+ const packageName = await this.#packageName();
1335
1465
  const violations = await Promise.all(files.map(async (file) => {
1336
1466
  const workspaceFile = `${this.sysPath}/${file}`;
1337
1467
  const content = await this.#read(workspaceFile);
1338
- return MaintainabilityContract.#measurePackageFile(file, this.#sourceOf(workspaceFile, content).sourceFile);
1468
+ return MaintainabilityContract.#measurePackageFile(file, this.#sourceOf(workspaceFile, content).sourceFile, MaintainabilityLimits.holdsBareErrors(packageName, file));
1339
1469
  }));
1340
1470
  return violations.flat();
1341
1471
  }
1342
- static #measurePackageFile(file, sourceFile) {
1472
+ async#packageName() {
1473
+ const manifest = `${this.sysPath}/package.json`;
1474
+ const text = this.#tree ? this.#tree.get(manifest) : existsSync(path4.join(this.#workspaceRoot, manifest)) ? await this.#read(manifest) : undefined;
1475
+ try {
1476
+ const { name } = JSON.parse(text ?? "{}");
1477
+ return typeof name === "string" ? name : null;
1478
+ } catch {
1479
+ return null;
1480
+ }
1481
+ }
1482
+ static #measurePackageFile(file, sourceFile, holdsBareErrors) {
1343
1483
  const violations = [];
1344
1484
  const maxLines = MaintainabilityLimits.packageFileMaxLines;
1345
1485
  const lineCount = MaintainabilityLimits.lineCountOf(sourceFile.text);
@@ -1370,6 +1510,16 @@ class MaintainabilityContract {
1370
1510
  memberCount,
1371
1511
  maxMembers: MaintainabilityLimits.classMaxMembers
1372
1512
  });
1513
+ const bareErrors = holdsBareErrors ? new BareErrorScanner().lines(sourceFile) : [];
1514
+ if (bareErrors.length)
1515
+ violations.push({
1516
+ kind: "bareError",
1517
+ rule: "akan.error.bare-error",
1518
+ key: file,
1519
+ file,
1520
+ line: bareErrors[0] ?? 1,
1521
+ lines: bareErrors
1522
+ });
1373
1523
  return violations;
1374
1524
  }
1375
1525
  static #numbered(items) {
@@ -1478,12 +1628,12 @@ class MaintainabilityContract {
1478
1628
  return await Promise.all(files.flat().map(async (file) => this.#sourceOf(file, await this.#read(file))));
1479
1629
  }
1480
1630
  #sourceOf(file, content) {
1481
- const scriptKind = file.endsWith(".tsx") ? ts12.ScriptKind.TSX : ts12.ScriptKind.TS;
1631
+ const scriptKind = file.endsWith(".tsx") ? ts13.ScriptKind.TSX : ts13.ScriptKind.TS;
1482
1632
  return {
1483
1633
  file,
1484
1634
  absolutePath: path4.join(this.#workspaceRoot, file),
1485
1635
  content,
1486
- sourceFile: ts12.createSourceFile(file, content, ts12.ScriptTarget.Latest, true, scriptKind)
1636
+ sourceFile: ts13.createSourceFile(file, content, ts13.ScriptTarget.Latest, true, scriptKind)
1487
1637
  };
1488
1638
  }
1489
1639
  async#readBaseline() {
@@ -1499,7 +1649,7 @@ class MaintainabilityContract {
1499
1649
  return null;
1500
1650
  const roots = [this.sysPath, ...this.#libNames.map((libName) => `libs/${libName}`)];
1501
1651
  const contract = new MaintainabilityContract(this.#workspaceRoot, this.#scope, this.#libNames);
1502
- contract.#tree = await new GitRevision(this.#workspaceRoot).filesAt(ref, (file) => /\.(tsx?|md)$/.test(file), roots);
1652
+ contract.#tree = await new GitRevision(this.#workspaceRoot).filesAt(ref, (file) => /\.(tsx?|md)$/.test(file) || file === `${this.sysPath}/package.json`, roots);
1503
1653
  return MaintainabilityBaseline.of(await contract.measure());
1504
1654
  }
1505
1655
  async#referenceRef() {
@@ -1544,6 +1694,8 @@ class MaintainabilityContract {
1544
1694
  }
1545
1695
  static #lineOf(lines, rule, key) {
1546
1696
  const from = Math.max(lines.findIndex((line) => line.includes(`${JSON.stringify(rule)}:`)), 0);
1697
+ if (key === MaintainabilityBaseline.totalKey)
1698
+ return from + 1;
1547
1699
  const idx = lines.findIndex((line, lineIdx) => lineIdx >= from && line.includes(`${JSON.stringify(key)}:`));
1548
1700
  return Math.max(idx + 1, 1);
1549
1701
  }
@@ -1574,6 +1726,7 @@ class MaintainabilityPaths {
1574
1726
  "akan.size.function",
1575
1727
  "akan.size.class",
1576
1728
  "akan.service.call-in-loop",
1729
+ "akan.error.bare-error",
1577
1730
  "akan.baseline.growth"
1578
1731
  ]);
1579
1732
  #specs;
@@ -1951,17 +2104,17 @@ import { readdir as readdir2, readFile as readFile3, stat } from "fs/promises";
1951
2104
  import path9 from "path";
1952
2105
  import { RESERVED_ROUTE_CONFIG_EXPORTS } from "akanjs/common";
1953
2106
  import ignore from "ignore";
1954
- import ts20 from "typescript";
2107
+ import ts21 from "typescript";
1955
2108
 
1956
2109
  // pkgs/@akanjs/devkit/commentDensityScanner.ts
1957
2110
  import path6 from "path";
1958
- import ts14 from "typescript";
2111
+ import ts15 from "typescript";
1959
2112
 
1960
2113
  // pkgs/@akanjs/devkit/sourceComments.ts
1961
- import ts13 from "typescript";
2114
+ import ts14 from "typescript";
1962
2115
 
1963
2116
  class SourceComments {
1964
- static #scanner = ts13.createScanner(ts13.ScriptTarget.Latest, false);
2117
+ static #scanner = ts14.createScanner(ts14.ScriptTarget.Latest, false);
1965
2118
  static of(sourceFile) {
1966
2119
  const comments = [];
1967
2120
  const scanGap = (start, end) => {
@@ -1969,22 +2122,22 @@ class SourceComments {
1969
2122
  return;
1970
2123
  const scanner = SourceComments.#scanner;
1971
2124
  scanner.setText(sourceFile.text, start, end - start);
1972
- for (let kind = scanner.scan();kind !== ts13.SyntaxKind.EndOfFileToken; kind = scanner.scan()) {
1973
- if (kind !== ts13.SyntaxKind.SingleLineCommentTrivia && kind !== ts13.SyntaxKind.MultiLineCommentTrivia)
2125
+ for (let kind = scanner.scan();kind !== ts14.SyntaxKind.EndOfFileToken; kind = scanner.scan()) {
2126
+ if (kind !== ts14.SyntaxKind.SingleLineCommentTrivia && kind !== ts14.SyntaxKind.MultiLineCommentTrivia)
1974
2127
  continue;
1975
2128
  comments.push(SourceComments.#commentOf(sourceFile, scanner.getTokenStart(), scanner.getTokenText()));
1976
2129
  }
1977
2130
  scanner.setText(undefined);
1978
2131
  };
1979
2132
  const visit = (node) => {
1980
- if (node.kind === ts13.SyntaxKind.JsxText)
2133
+ if (node.kind === ts14.SyntaxKind.JsxText)
1981
2134
  return;
1982
- if (ts13.isToken(node)) {
2135
+ if (ts14.isToken(node)) {
1983
2136
  scanGap(node.pos, node.getStart(sourceFile));
1984
2137
  return;
1985
2138
  }
1986
2139
  const children = [];
1987
- ts13.forEachChild(node, (child) => {
2140
+ ts14.forEachChild(node, (child) => {
1988
2141
  children.push(child);
1989
2142
  }, (nodes) => {
1990
2143
  children.push(...nodes);
@@ -2087,7 +2240,7 @@ class CommentDensityScanner {
2087
2240
  static #isMeasured({ file, sourceFile }) {
2088
2241
  if (/\.(test|spec)\.tsx?$/.test(file) || path6.basename(file) === "guards.ts")
2089
2242
  return false;
2090
- return !sourceFile.statements.every((statement) => ts14.isExportDeclaration(statement) || ts14.isExpressionStatement(statement) && ts14.isStringLiteral(statement.expression));
2243
+ return !sourceFile.statements.every((statement) => ts15.isExportDeclaration(statement) || ts15.isExpressionStatement(statement) && ts15.isStringLiteral(statement.expression));
2091
2244
  }
2092
2245
  }
2093
2246
 
@@ -2115,7 +2268,7 @@ class DeprecatedCommentScanner {
2115
2268
 
2116
2269
  // pkgs/@akanjs/devkit/formSetterScanner.ts
2117
2270
  import { capitalize, formSetterNames } from "akanjs/common";
2118
- import ts15 from "typescript";
2271
+ import ts16 from "typescript";
2119
2272
 
2120
2273
  class FormSetterScanner {
2121
2274
  static #constantPath = /(?:^|\/)lib\/([^_/][^/]*)\/\1\.constant\.ts$/;
@@ -2134,7 +2287,7 @@ class FormSetterScanner {
2134
2287
  const fullModelClasses = new Set([`${className}Input`, `${className}Object`, `Light${className}`, className]);
2135
2288
  const keys = new Set(FormSetterScanner.#baseFields);
2136
2289
  for (const statement of sourceFile.statements)
2137
- if (ts15.isClassDeclaration(statement) && statement.name && fullModelClasses.has(statement.name.text))
2290
+ if (ts16.isClassDeclaration(statement) && statement.name && fullModelClasses.has(statement.name.text))
2138
2291
  for (const key of FormSetterScanner.#viaFieldKeysOf(statement))
2139
2292
  keys.add(key);
2140
2293
  for (const key of keys)
@@ -2143,33 +2296,33 @@ class FormSetterScanner {
2143
2296
  return setters;
2144
2297
  }
2145
2298
  static #viaFieldKeysOf(declaration) {
2146
- const via = declaration.heritageClauses?.find((clause) => clause.token === ts15.SyntaxKind.ExtendsKeyword)?.types[0]?.expression;
2147
- if (!via || !ts15.isCallExpression(via))
2299
+ const via = declaration.heritageClauses?.find((clause) => clause.token === ts16.SyntaxKind.ExtendsKeyword)?.types[0]?.expression;
2300
+ if (!via || !ts16.isCallExpression(via))
2148
2301
  return [];
2149
2302
  return via.arguments.flatMap((argument) => {
2150
- if (!ts15.isArrowFunction(argument) && !ts15.isFunctionExpression(argument))
2303
+ if (!ts16.isArrowFunction(argument) && !ts16.isFunctionExpression(argument))
2151
2304
  return [];
2152
2305
  const fields = FormSetterScanner.#returnedObjectOf(argument.body);
2153
- return (fields?.properties ?? []).flatMap((property) => property.name && (ts15.isIdentifier(property.name) || ts15.isStringLiteral(property.name)) ? [property.name.text] : []);
2306
+ return (fields?.properties ?? []).flatMap((property) => property.name && (ts16.isIdentifier(property.name) || ts16.isStringLiteral(property.name)) ? [property.name.text] : []);
2154
2307
  });
2155
2308
  }
2156
2309
  static #returnedObjectOf(body) {
2157
2310
  let expression = body;
2158
- if (ts15.isBlock(body))
2159
- expression = body.statements.find(ts15.isReturnStatement)?.expression;
2160
- while (expression && (ts15.isParenthesizedExpression(expression) || ts15.isAsExpression(expression)))
2311
+ if (ts16.isBlock(body))
2312
+ expression = body.statements.find(ts16.isReturnStatement)?.expression;
2313
+ while (expression && (ts16.isParenthesizedExpression(expression) || ts16.isAsExpression(expression)))
2161
2314
  expression = expression.expression;
2162
- return expression && ts15.isObjectLiteralExpression(expression) ? expression : null;
2315
+ return expression && ts16.isObjectLiteralExpression(expression) ? expression : null;
2163
2316
  }
2164
2317
  #scanFile({ file, sourceFile }, fieldSetters) {
2165
2318
  const wrapped = [];
2166
2319
  const visit = (node) => {
2167
- if (ts15.isJsxAttribute(node)) {
2320
+ if (ts16.isJsxAttribute(node)) {
2168
2321
  const setter = FormSetterScanner.#wrappedSetterOf(node, fieldSetters);
2169
2322
  if (setter)
2170
2323
  wrapped.push({ setter, line: FormSetterScanner.#lineOf(sourceFile, node) });
2171
2324
  }
2172
- ts15.forEachChild(node, visit);
2325
+ ts16.forEachChild(node, visit);
2173
2326
  };
2174
2327
  visit(sourceFile);
2175
2328
  if (!wrapped.length)
@@ -2188,13 +2341,13 @@ class FormSetterScanner {
2188
2341
  ];
2189
2342
  }
2190
2343
  static #wrappedSetterOf(attribute, fieldSetters) {
2191
- if (!ts15.isIdentifier(attribute.name) || !/^on[A-Z]/.test(attribute.name.text))
2344
+ if (!ts16.isIdentifier(attribute.name) || !/^on[A-Z]/.test(attribute.name.text))
2192
2345
  return null;
2193
2346
  const initializer = attribute.initializer;
2194
- if (!initializer || !ts15.isJsxExpression(initializer) || !initializer.expression)
2347
+ if (!initializer || !ts16.isJsxExpression(initializer) || !initializer.expression)
2195
2348
  return null;
2196
2349
  const handler = initializer.expression;
2197
- if (!ts15.isArrowFunction(handler) && !ts15.isFunctionExpression(handler))
2350
+ if (!ts16.isArrowFunction(handler) && !ts16.isFunctionExpression(handler))
2198
2351
  return null;
2199
2352
  if (!handler.parameters.length)
2200
2353
  return null;
@@ -2205,14 +2358,14 @@ class FormSetterScanner {
2205
2358
  const visit = (current) => {
2206
2359
  if (found)
2207
2360
  return;
2208
- if (ts15.isCallExpression(current) && ts15.isPropertyAccessExpression(current.expression)) {
2361
+ if (ts16.isCallExpression(current) && ts16.isPropertyAccessExpression(current.expression)) {
2209
2362
  const { expression, name } = current.expression;
2210
- if (ts15.isPropertyAccessExpression(expression) && ts15.isIdentifier(expression.expression) && expression.expression.text === "st" && expression.name.text === "do" && fieldSetters.has(name.text)) {
2363
+ if (ts16.isPropertyAccessExpression(expression) && ts16.isIdentifier(expression.expression) && expression.expression.text === "st" && expression.name.text === "do" && fieldSetters.has(name.text)) {
2211
2364
  found = name.text;
2212
2365
  return;
2213
2366
  }
2214
2367
  }
2215
- ts15.forEachChild(current, visit);
2368
+ ts16.forEachChild(current, visit);
2216
2369
  };
2217
2370
  visit(node);
2218
2371
  return found;
@@ -2224,7 +2377,7 @@ class FormSetterScanner {
2224
2377
 
2225
2378
  // pkgs/@akanjs/devkit/kindBranchScanner.ts
2226
2379
  import path7 from "path";
2227
- import ts16 from "typescript";
2380
+ import ts17 from "typescript";
2228
2381
 
2229
2382
  class KindBranchScanner {
2230
2383
  static rule = "akan.global.kind-branch";
@@ -2232,10 +2385,10 @@ class KindBranchScanner {
2232
2385
  static #kindName = /(Kind|Type|Mode)$/;
2233
2386
  static #kindSubject = /^(kind|type|mode)$|[a-z](Kind|Type|Mode)$/;
2234
2387
  static #equalities = new Set([
2235
- ts16.SyntaxKind.EqualsEqualsEqualsToken,
2236
- ts16.SyntaxKind.ExclamationEqualsEqualsToken,
2237
- ts16.SyntaxKind.EqualsEqualsToken,
2238
- ts16.SyntaxKind.ExclamationEqualsToken
2388
+ ts17.SyntaxKind.EqualsEqualsEqualsToken,
2389
+ ts17.SyntaxKind.ExclamationEqualsEqualsToken,
2390
+ ts17.SyntaxKind.EqualsEqualsToken,
2391
+ ts17.SyntaxKind.ExclamationEqualsToken
2239
2392
  ]);
2240
2393
  scan(sourceFiles) {
2241
2394
  const enums = sourceFiles.flatMap((sourceFile) => KindBranchScanner.#enumsOf(sourceFile));
@@ -2287,7 +2440,7 @@ class KindBranchScanner {
2287
2440
  static #sitesIn({ file, sourceFile }, ownersByValue) {
2288
2441
  const sites = [];
2289
2442
  const record = (literal, subject) => {
2290
- if (!ts16.isStringLiteralLike(literal) || !ownersByValue.has(literal.text))
2443
+ if (!ts17.isStringLiteralLike(literal) || !ownersByValue.has(literal.text))
2291
2444
  return;
2292
2445
  if (!KindBranchScanner.#isKindSubject(subject))
2293
2446
  return;
@@ -2298,28 +2451,28 @@ class KindBranchScanner {
2298
2451
  });
2299
2452
  };
2300
2453
  const visit = (node) => {
2301
- if (ts16.isBinaryExpression(node) && KindBranchScanner.#equalities.has(node.operatorToken.kind)) {
2454
+ if (ts17.isBinaryExpression(node) && KindBranchScanner.#equalities.has(node.operatorToken.kind)) {
2302
2455
  record(node.left, node.right);
2303
2456
  record(node.right, node.left);
2304
- } else if (ts16.isCaseClause(node) && ts16.isSwitchStatement(node.parent.parent))
2457
+ } else if (ts17.isCaseClause(node) && ts17.isSwitchStatement(node.parent.parent))
2305
2458
  record(node.expression, node.parent.parent.expression);
2306
- ts16.forEachChild(node, visit);
2459
+ ts17.forEachChild(node, visit);
2307
2460
  };
2308
2461
  visit(sourceFile);
2309
2462
  return sites;
2310
2463
  }
2311
2464
  static #isKindSubject(subject) {
2312
2465
  let current = subject;
2313
- while (ts16.isParenthesizedExpression(current) || ts16.isAsExpression(current) || ts16.isNonNullExpression(current))
2466
+ while (ts17.isParenthesizedExpression(current) || ts17.isAsExpression(current) || ts17.isNonNullExpression(current))
2314
2467
  current = current.expression;
2315
- const name = ts16.isIdentifier(current) ? current.text : ts16.isPropertyAccessExpression(current) ? current.name.text : ts16.isElementAccessExpression(current) && ts16.isStringLiteralLike(current.argumentExpression) ? current.argumentExpression.text : "";
2468
+ const name = ts17.isIdentifier(current) ? current.text : ts17.isPropertyAccessExpression(current) ? current.name.text : ts17.isElementAccessExpression(current) && ts17.isStringLiteralLike(current.argumentExpression) ? current.argumentExpression.text : "";
2316
2469
  return KindBranchScanner.#kindSubject.test(name);
2317
2470
  }
2318
2471
  static #enumsOf({ file, sourceFile }) {
2319
2472
  if (!/^(apps|libs)\/[^/]+\/lib\/.+\.constant\.ts$/.test(file))
2320
2473
  return [];
2321
2474
  return sourceFile.statements.flatMap((statement) => {
2322
- if (!ts16.isClassDeclaration(statement) || !statement.name)
2475
+ if (!ts17.isClassDeclaration(statement) || !statement.name)
2323
2476
  return [];
2324
2477
  if (!KindBranchScanner.#kindName.test(statement.name.text))
2325
2478
  return [];
@@ -2344,16 +2497,16 @@ class KindBranchScanner {
2344
2497
  static #enumValuesOf(statement) {
2345
2498
  for (const clause of statement.heritageClauses ?? [])
2346
2499
  for (const { expression } of clause.types) {
2347
- if (!ts16.isCallExpression(expression) || !ts16.isIdentifier(expression.expression))
2500
+ if (!ts17.isCallExpression(expression) || !ts17.isIdentifier(expression.expression))
2348
2501
  continue;
2349
2502
  if (expression.expression.text !== "enumOf")
2350
2503
  continue;
2351
2504
  let list = expression.arguments[1];
2352
- while (list && (ts16.isAsExpression(list) || ts16.isParenthesizedExpression(list)))
2505
+ while (list && (ts17.isAsExpression(list) || ts17.isParenthesizedExpression(list)))
2353
2506
  list = list.expression;
2354
- if (!list || !ts16.isArrayLiteralExpression(list))
2507
+ if (!list || !ts17.isArrayLiteralExpression(list))
2355
2508
  return null;
2356
- return list.elements.filter(ts16.isStringLiteralLike).map(({ text }) => text);
2509
+ return list.elements.filter(ts17.isStringLiteralLike).map(({ text }) => text);
2357
2510
  }
2358
2511
  return null;
2359
2512
  }
@@ -2367,6 +2520,7 @@ class MaintainabilityExceptionScanner {
2367
2520
  static rule = "akan.baseline.exceptions";
2368
2521
  static #shapeFix = "Many reasoned exceptions under one rule mean its threshold is wrong: fix the limit in MaintainabilityLimits rather than record another. Otherwise shrink the code, and `akan lint` lowers each entry and drops it once it passes.";
2369
2522
  static #correctnessFix = "A write rule takes no exception: send the writes through one store action and one endpoint (`akan workflow plan add-mutation`), and `akan lint` drops the entry.";
2523
+ static #bareErrorFix = "A bare Error takes no exception: construct an `AkanError` subclass with a code, and `akan lint` lowers the entries as they go.";
2370
2524
  async scan(workspaceRoot) {
2371
2525
  const sysPaths = await Promise.all(["apps", "libs", "pkgs"].map((sysRoot) => MaintainabilityExceptionScanner.#dirsIn(workspaceRoot, sysRoot)));
2372
2526
  const warnings = await Promise.all(sysPaths.flat().map((sysPath) => MaintainabilityExceptionScanner.#scanSys(workspaceRoot, sysPath)));
@@ -2412,7 +2566,7 @@ class MaintainabilityExceptionScanner {
2412
2566
  line: locations[0]?.line ?? 1,
2413
2567
  message: `${sysPath} carries ${reasonedNum} reasoned exception${reasonedNum === 1 ? "" : "s"} and ${adoptedNum} adopted-debt entr${adoptedNum === 1 ? "y" : "ies"} for ${rule}: ${listed.join(", ")}.`,
2414
2568
  locations,
2415
- fix: MaintainabilityBaseline.reasonedRules.has(rule) ? MaintainabilityExceptionScanner.#shapeFix : MaintainabilityExceptionScanner.#correctnessFix
2569
+ fix: MaintainabilityBaseline.reasonedRules.has(rule) ? MaintainabilityExceptionScanner.#shapeFix : rule === "akan.error.bare-error" ? MaintainabilityExceptionScanner.#bareErrorFix : MaintainabilityExceptionScanner.#correctnessFix
2416
2570
  };
2417
2571
  }
2418
2572
  static #lineOf(lines, rule, key) {
@@ -2422,10 +2576,10 @@ class MaintainabilityExceptionScanner {
2422
2576
  }
2423
2577
 
2424
2578
  // pkgs/@akanjs/devkit/ssrScanner.ts
2425
- import ts18 from "typescript";
2579
+ import ts19 from "typescript";
2426
2580
 
2427
2581
  // pkgs/@akanjs/devkit/renderMutationScanner.ts
2428
- import ts17 from "typescript";
2582
+ import ts18 from "typescript";
2429
2583
 
2430
2584
  class RenderMutationScanner {
2431
2585
  static rule = "akan.ssr.render-mutation";
@@ -2454,7 +2608,7 @@ class RenderMutationScanner {
2454
2608
  const helper = follow ? RenderMutationScanner.#helperOf(node, functions) : undefined;
2455
2609
  if (helper)
2456
2610
  helpers.add(helper);
2457
- ts17.forEachChild(node, (child) => visit(child, follow));
2611
+ ts18.forEachChild(node, (child) => visit(child, follow));
2458
2612
  };
2459
2613
  for (const body of RenderMutationScanner.#renderBodiesOf(sourceFile, functions))
2460
2614
  visit(body, true);
@@ -2471,7 +2625,7 @@ class RenderMutationScanner {
2471
2625
  }));
2472
2626
  }
2473
2627
  #isRenderMutation(file, node, fetchNames) {
2474
- if (!ts17.isCallExpression(node))
2628
+ if (!ts18.isCallExpression(node))
2475
2629
  return false;
2476
2630
  const name = RenderMutationScanner.#endpointOf(node.expression, fetchNames);
2477
2631
  if (!name || !this.#mutations.isMutation(file, name))
@@ -2479,64 +2633,64 @@ class RenderMutationScanner {
2479
2633
  return !RenderMutationScanner.#optsIn(node, this.#mutations.policyIndexOf(file, name));
2480
2634
  }
2481
2635
  static #isEventHandler(node) {
2482
- return ts17.isJsxAttribute(node) && ts17.isIdentifier(node.name) && /^on[A-Z]/.test(node.name.text);
2636
+ return ts18.isJsxAttribute(node) && ts18.isIdentifier(node.name) && /^on[A-Z]/.test(node.name.text);
2483
2637
  }
2484
2638
  static #endpointOf(callee, fetchNames) {
2485
- if (ts17.isPropertyAccessExpression(callee))
2639
+ if (ts18.isPropertyAccessExpression(callee))
2486
2640
  return RenderMutationScanner.#isFetch(callee.expression, fetchNames) ? callee.name.text : null;
2487
- if (ts17.isElementAccessExpression(callee) && ts17.isStringLiteralLike(callee.argumentExpression))
2641
+ if (ts18.isElementAccessExpression(callee) && ts18.isStringLiteralLike(callee.argumentExpression))
2488
2642
  return RenderMutationScanner.#isFetch(callee.expression, fetchNames) ? callee.argumentExpression.text : null;
2489
2643
  return null;
2490
2644
  }
2491
2645
  static #isFetch(expression, fetchNames) {
2492
- return ts17.isIdentifier(expression) && fetchNames.has(expression.text);
2646
+ return ts18.isIdentifier(expression) && fetchNames.has(expression.text);
2493
2647
  }
2494
2648
  static #optsIn(call, policyIndex) {
2495
2649
  if (policyIndex === null)
2496
2650
  return false;
2497
2651
  const leading = call.arguments.slice(0, policyIndex + 1);
2498
- if (leading.some((argument) => ts17.isSpreadElement(argument)))
2652
+ if (leading.some((argument) => ts18.isSpreadElement(argument)))
2499
2653
  return true;
2500
2654
  const policy = leading[policyIndex];
2501
2655
  return policy ? RenderMutationScanner.#policyOptsIn(policy) : false;
2502
2656
  }
2503
2657
  static #policyOptsIn(argument) {
2504
2658
  const policy = RenderMutationScanner.#unwrap(argument);
2505
- if (!ts17.isObjectLiteralExpression(policy))
2659
+ if (!ts18.isObjectLiteralExpression(policy))
2506
2660
  return !RenderMutationScanner.#cannotBePolicy(policy);
2507
2661
  return policy.properties.some((property) => {
2508
- if (ts17.isSpreadAssignment(property))
2662
+ if (ts18.isSpreadAssignment(property))
2509
2663
  return true;
2510
- if (!ts17.isPropertyAssignment(property) && !ts17.isShorthandPropertyAssignment(property))
2664
+ if (!ts18.isPropertyAssignment(property) && !ts18.isShorthandPropertyAssignment(property))
2511
2665
  return false;
2512
- if (!(ts17.isIdentifier(property.name) || ts17.isStringLiteral(property.name)))
2666
+ if (!(ts18.isIdentifier(property.name) || ts18.isStringLiteral(property.name)))
2513
2667
  return false;
2514
2668
  if (property.name.text !== "duringRender")
2515
2669
  return false;
2516
- if (ts17.isShorthandPropertyAssignment(property))
2670
+ if (ts18.isShorthandPropertyAssignment(property))
2517
2671
  return true;
2518
2672
  const value = RenderMutationScanner.#unwrap(property.initializer);
2519
- return value.kind !== ts17.SyntaxKind.FalseKeyword && !(ts17.isIdentifier(value) && value.text === "undefined");
2673
+ return value.kind !== ts18.SyntaxKind.FalseKeyword && !(ts18.isIdentifier(value) && value.text === "undefined");
2520
2674
  });
2521
2675
  }
2522
2676
  static #unwrap(expression) {
2523
2677
  let current = expression;
2524
- while (ts17.isParenthesizedExpression(current) || ts17.isAsExpression(current) || ts17.isSatisfiesExpression(current) || ts17.isNonNullExpression(current) || ts17.isTypeAssertionExpression(current))
2678
+ while (ts18.isParenthesizedExpression(current) || ts18.isAsExpression(current) || ts18.isSatisfiesExpression(current) || ts18.isNonNullExpression(current) || ts18.isTypeAssertionExpression(current))
2525
2679
  current = current.expression;
2526
2680
  return current;
2527
2681
  }
2528
2682
  static #cannotBePolicy(expression) {
2529
- if (ts17.isIdentifier(expression))
2683
+ if (ts18.isIdentifier(expression))
2530
2684
  return expression.text === "undefined";
2531
- return ts17.isLiteralExpression(expression) || ts17.isNoSubstitutionTemplateLiteral(expression) || ts17.isTemplateExpression(expression) || ts17.isArrayLiteralExpression(expression) || ts17.isArrowFunction(expression) || ts17.isFunctionExpression(expression) || ts17.isVoidExpression(expression) || ts17.isPrefixUnaryExpression(expression) || [ts17.SyntaxKind.NullKeyword, ts17.SyntaxKind.TrueKeyword, ts17.SyntaxKind.FalseKeyword].includes(expression.kind);
2685
+ return ts18.isLiteralExpression(expression) || ts18.isNoSubstitutionTemplateLiteral(expression) || ts18.isTemplateExpression(expression) || ts18.isArrayLiteralExpression(expression) || ts18.isArrowFunction(expression) || ts18.isFunctionExpression(expression) || ts18.isVoidExpression(expression) || ts18.isPrefixUnaryExpression(expression) || [ts18.SyntaxKind.NullKeyword, ts18.SyntaxKind.TrueKeyword, ts18.SyntaxKind.FalseKeyword].includes(expression.kind);
2532
2686
  }
2533
2687
  static #fetchBindingsOf(sourceFile) {
2534
2688
  const names = new Set;
2535
2689
  for (const statement of sourceFile.statements) {
2536
- if (!ts17.isImportDeclaration(statement) || statement.importClause?.isTypeOnly)
2690
+ if (!ts18.isImportDeclaration(statement) || statement.importClause?.isTypeOnly)
2537
2691
  continue;
2538
2692
  const bindings = statement.importClause?.namedBindings;
2539
- if (!bindings || !ts17.isNamedImports(bindings))
2693
+ if (!bindings || !ts18.isNamedImports(bindings))
2540
2694
  continue;
2541
2695
  for (const element of bindings.elements)
2542
2696
  if (!element.isTypeOnly && (element.propertyName ?? element.name).text === "fetch")
@@ -2547,35 +2701,35 @@ class RenderMutationScanner {
2547
2701
  static #functionsOf(sourceFile) {
2548
2702
  const functions = new Map;
2549
2703
  for (const statement of sourceFile.statements) {
2550
- if (ts17.isFunctionDeclaration(statement) && statement.name && statement.body)
2704
+ if (ts18.isFunctionDeclaration(statement) && statement.name && statement.body)
2551
2705
  functions.set(statement.name.text, statement.body);
2552
- if (!ts17.isVariableStatement(statement))
2706
+ if (!ts18.isVariableStatement(statement))
2553
2707
  continue;
2554
2708
  for (const declaration of statement.declarationList.declarations) {
2555
2709
  const initializer = declaration.initializer && RenderMutationScanner.#unwrap(declaration.initializer);
2556
- if (!ts17.isIdentifier(declaration.name) || !initializer)
2710
+ if (!ts18.isIdentifier(declaration.name) || !initializer)
2557
2711
  continue;
2558
- if (ts17.isArrowFunction(initializer) || ts17.isFunctionExpression(initializer))
2712
+ if (ts18.isArrowFunction(initializer) || ts18.isFunctionExpression(initializer))
2559
2713
  functions.set(declaration.name.text, initializer.body);
2560
2714
  }
2561
2715
  }
2562
2716
  return functions;
2563
2717
  }
2564
2718
  static #helperOf(node, functions) {
2565
- const callee = ts17.isCallExpression(node) ? node.expression : ts17.isJsxSelfClosingElement(node) || ts17.isJsxOpeningElement(node) ? node.tagName : undefined;
2566
- return callee && ts17.isIdentifier(callee) ? functions.get(callee.text) : undefined;
2719
+ const callee = ts18.isCallExpression(node) ? node.expression : ts18.isJsxSelfClosingElement(node) || ts18.isJsxOpeningElement(node) ? node.tagName : undefined;
2720
+ return callee && ts18.isIdentifier(callee) ? functions.get(callee.text) : undefined;
2567
2721
  }
2568
2722
  static #renderBodiesOf(sourceFile, functions) {
2569
2723
  const bodies = [];
2570
- const bodyOf = (node) => ts17.isIdentifier(node) ? functions.get(node.text) : node;
2724
+ const bodyOf = (node) => ts18.isIdentifier(node) ? functions.get(node.text) : node;
2571
2725
  const visit = (node) => {
2572
- if (ts17.isCallExpression(node) && ts17.isPropertyAccessExpression(node.expression) && RenderMutationScanner.#stages.has(node.expression.name.text) && RenderMutationScanner.#isRouteChain(node.expression.expression))
2726
+ if (ts18.isCallExpression(node) && ts18.isPropertyAccessExpression(node.expression) && RenderMutationScanner.#stages.has(node.expression.name.text) && RenderMutationScanner.#isRouteChain(node.expression.expression))
2573
2727
  for (const argument of node.arguments) {
2574
2728
  const body = bodyOf(argument);
2575
2729
  if (body)
2576
2730
  bodies.push(body);
2577
2731
  }
2578
- ts17.forEachChild(node, visit);
2732
+ ts18.forEachChild(node, visit);
2579
2733
  };
2580
2734
  visit(sourceFile);
2581
2735
  for (const statement of sourceFile.statements) {
@@ -2587,24 +2741,24 @@ class RenderMutationScanner {
2587
2741
  }
2588
2742
  static #isRouteChain(expression) {
2589
2743
  let current = expression;
2590
- while (ts17.isCallExpression(current)) {
2591
- if (ts17.isIdentifier(current.expression))
2744
+ while (ts18.isCallExpression(current)) {
2745
+ if (ts18.isIdentifier(current.expression))
2592
2746
  return RenderMutationScanner.#builders.has(current.expression.text);
2593
- if (!ts17.isPropertyAccessExpression(current.expression))
2747
+ if (!ts18.isPropertyAccessExpression(current.expression))
2594
2748
  return false;
2595
2749
  current = current.expression.expression;
2596
2750
  }
2597
2751
  return false;
2598
2752
  }
2599
2753
  static #legacyPageOf(statement, functions) {
2600
- if (ts17.isFunctionDeclaration(statement))
2601
- return statement.modifiers?.some((modifier) => modifier.kind === ts17.SyntaxKind.DefaultKeyword) ? statement.body : undefined;
2602
- if (!ts17.isExportAssignment(statement))
2754
+ if (ts18.isFunctionDeclaration(statement))
2755
+ return statement.modifiers?.some((modifier) => modifier.kind === ts18.SyntaxKind.DefaultKeyword) ? statement.body : undefined;
2756
+ if (!ts18.isExportAssignment(statement))
2603
2757
  return;
2604
2758
  const expression = RenderMutationScanner.#unwrap(statement.expression);
2605
- if (ts17.isIdentifier(expression))
2759
+ if (ts18.isIdentifier(expression))
2606
2760
  return functions.get(expression.text);
2607
- return ts17.isArrowFunction(expression) || ts17.isFunctionExpression(expression) ? expression.body : undefined;
2761
+ return ts18.isArrowFunction(expression) || ts18.isFunctionExpression(expression) ? expression.body : undefined;
2608
2762
  }
2609
2763
  }
2610
2764
 
@@ -2689,18 +2843,18 @@ class SsrScanner {
2689
2843
  return warnings;
2690
2844
  }
2691
2845
  #isMountEffect(sourceFile, node) {
2692
- if (!ts18.isCallExpression(node))
2846
+ if (!ts19.isCallExpression(node))
2693
2847
  return false;
2694
2848
  const callee = node.expression.getText(sourceFile);
2695
2849
  if (callee !== "useEffect" && callee !== "useLayoutEffect")
2696
2850
  return false;
2697
2851
  const deps = node.arguments[1];
2698
- return !!deps && ts18.isArrayLiteralExpression(deps) && deps.elements.length === 0;
2852
+ return !!deps && ts19.isArrayLiteralExpression(deps) && deps.elements.length === 0;
2699
2853
  }
2700
2854
  #getLoadCalls(sourceFile, node) {
2701
2855
  const calls = [];
2702
2856
  SsrScanner.#walk(node, (child) => {
2703
- if (!ts18.isCallExpression(child))
2857
+ if (!ts19.isCallExpression(child))
2704
2858
  return;
2705
2859
  const callee = child.expression.getText(sourceFile);
2706
2860
  if (/^fetch\.[a-z]/.test(callee) || /^st\.do\.(init|get|view|load|list|count|insight)[A-Z]/.test(callee))
@@ -2713,7 +2867,7 @@ class SsrScanner {
2713
2867
  return [];
2714
2868
  const warnings = [];
2715
2869
  SsrScanner.#walk(sourceFile.sourceFile, (node) => {
2716
- if (ts18.isCallExpression(node) && node.expression.getText(sourceFile.sourceFile) === "useState")
2870
+ if (ts19.isCallExpression(node) && node.expression.getText(sourceFile.sourceFile) === "useState")
2717
2871
  warnings.push(fileWarning("akan.ssr.template-client-state", "ssr", sourceFile.file, "Template holds form state in useState. Templates are store-driven and carry no local state.", this.#getLine(sourceFile.sourceFile, node)));
2718
2872
  });
2719
2873
  return warnings;
@@ -2756,14 +2910,14 @@ class SsrScanner {
2756
2910
  return components;
2757
2911
  }
2758
2912
  #getComponentNodes(statement) {
2759
- if (ts18.isFunctionDeclaration(statement) && statement.body)
2913
+ if (ts19.isFunctionDeclaration(statement) && statement.body)
2760
2914
  return [{ name: statement.name?.text ?? "default", node: statement.body }];
2761
- if (!ts18.isVariableStatement(statement))
2915
+ if (!ts19.isVariableStatement(statement))
2762
2916
  return [];
2763
2917
  return statement.declarationList.declarations.flatMap((declaration) => {
2764
- if (!ts18.isIdentifier(declaration.name) || !declaration.initializer)
2918
+ if (!ts19.isIdentifier(declaration.name) || !declaration.initializer)
2765
2919
  return [];
2766
- if (!ts18.isArrowFunction(declaration.initializer) && !ts18.isFunctionExpression(declaration.initializer))
2920
+ if (!ts19.isArrowFunction(declaration.initializer) && !ts19.isFunctionExpression(declaration.initializer))
2767
2921
  return [];
2768
2922
  return [{ name: declaration.name.text, node: declaration.initializer }];
2769
2923
  });
@@ -2771,7 +2925,7 @@ class SsrScanner {
2771
2925
  #getTouches(sourceFile, node) {
2772
2926
  const touches = [];
2773
2927
  SsrScanner.#walk(node, (child) => {
2774
- if (ts18.isCallExpression(child)) {
2928
+ if (ts19.isCallExpression(child)) {
2775
2929
  const callee = child.expression.getText(sourceFile);
2776
2930
  const bareName = callee.split(".").pop() ?? callee;
2777
2931
  if (callee === "createContext" || callee === "lazy")
@@ -2779,9 +2933,9 @@ class SsrScanner {
2779
2933
  else if (/^use[A-Z]/.test(bareName) && !SsrScanner.#serverSafeCalls.has(bareName))
2780
2934
  touches.push(bareName);
2781
2935
  }
2782
- if (ts18.isJsxAttribute(child) && /^on[A-Z]/.test(child.name.getText(sourceFile)))
2936
+ if (ts19.isJsxAttribute(child) && /^on[A-Z]/.test(child.name.getText(sourceFile)))
2783
2937
  touches.push(child.name.getText(sourceFile));
2784
- if (ts18.isPropertyAccessExpression(child)) {
2938
+ if (ts19.isPropertyAccessExpression(child)) {
2785
2939
  const root = getAccessRoot(child);
2786
2940
  if (root === "st")
2787
2941
  touches.push("st");
@@ -2794,7 +2948,7 @@ class SsrScanner {
2794
2948
  #getTagNames(sourceFile, node) {
2795
2949
  const tags = new Set;
2796
2950
  SsrScanner.#walk(node, (child) => {
2797
- if (ts18.isJsxOpeningElement(child) || ts18.isJsxSelfClosingElement(child))
2951
+ if (ts19.isJsxOpeningElement(child) || ts19.isJsxSelfClosingElement(child))
2798
2952
  tags.add(child.tagName.getText(sourceFile).split(".")[0]);
2799
2953
  });
2800
2954
  return tags;
@@ -2802,7 +2956,7 @@ class SsrScanner {
2802
2956
  #getMass(node) {
2803
2957
  let mass = 0;
2804
2958
  SsrScanner.#walk(node, (child) => {
2805
- if (ts18.isJsxOpeningElement(child) || ts18.isJsxSelfClosingElement(child))
2959
+ if (ts19.isJsxOpeningElement(child) || ts19.isJsxSelfClosingElement(child))
2806
2960
  mass += 1;
2807
2961
  });
2808
2962
  return mass;
@@ -2810,30 +2964,30 @@ class SsrScanner {
2810
2964
  static #walk(node, visit) {
2811
2965
  const walk = (child) => {
2812
2966
  visit(child);
2813
- ts18.forEachChild(child, walk);
2967
+ ts19.forEachChild(child, walk);
2814
2968
  };
2815
- ts18.forEachChild(node, walk);
2969
+ ts19.forEachChild(node, walk);
2816
2970
  }
2817
2971
  #hasUseClient(sourceFile) {
2818
2972
  const first = sourceFile.statements[0];
2819
- if (!first || !ts18.isExpressionStatement(first) || !ts18.isStringLiteral(first.expression))
2973
+ if (!first || !ts19.isExpressionStatement(first) || !ts19.isStringLiteral(first.expression))
2820
2974
  return false;
2821
2975
  return first.expression.text === "use client";
2822
2976
  }
2823
2977
  #hasVendorImport(sourceFile) {
2824
- return sourceFile.statements.some((statement) => ts18.isImportDeclaration(statement) && isVendorSpecifier(getSpecifier(statement)));
2978
+ return sourceFile.statements.some((statement) => ts19.isImportDeclaration(statement) && isVendorSpecifier(getSpecifier(statement)));
2825
2979
  }
2826
2980
  #getVendorNames(sourceFile) {
2827
2981
  const names = new Set;
2828
2982
  for (const statement of sourceFile.statements) {
2829
- if (!ts18.isImportDeclaration(statement) || !isVendorSpecifier(getSpecifier(statement)))
2983
+ if (!ts19.isImportDeclaration(statement) || !isVendorSpecifier(getSpecifier(statement)))
2830
2984
  continue;
2831
2985
  const clause = statement.importClause;
2832
2986
  if (clause?.name)
2833
2987
  names.add(clause.name.text);
2834
- if (clause?.namedBindings && ts18.isNamespaceImport(clause.namedBindings))
2988
+ if (clause?.namedBindings && ts19.isNamespaceImport(clause.namedBindings))
2835
2989
  names.add(clause.namedBindings.name.text);
2836
- if (clause?.namedBindings && ts18.isNamedImports(clause.namedBindings))
2990
+ if (clause?.namedBindings && ts19.isNamedImports(clause.namedBindings))
2837
2991
  for (const element of clause.namedBindings.elements)
2838
2992
  names.add(element.name.text);
2839
2993
  }
@@ -2841,10 +2995,10 @@ class SsrScanner {
2841
2995
  }
2842
2996
  #importsClientRuntime(sourceFile) {
2843
2997
  for (const statement of sourceFile.statements) {
2844
- if (!ts18.isImportDeclaration(statement))
2998
+ if (!ts19.isImportDeclaration(statement))
2845
2999
  continue;
2846
3000
  const bindings = statement.importClause?.namedBindings;
2847
- if (!bindings || !ts18.isNamedImports(bindings))
3001
+ if (!bindings || !ts19.isNamedImports(bindings))
2848
3002
  continue;
2849
3003
  if (bindings.elements.some((element) => SsrScanner.#clientRuntimeImports.has(element.name.text)))
2850
3004
  return true;
@@ -2895,7 +3049,7 @@ function getShare(serverMass, clientMass) {
2895
3049
  return total === 0 ? 1 : serverMass / total;
2896
3050
  }
2897
3051
  function getSpecifier(statement) {
2898
- return ts18.isStringLiteral(statement.moduleSpecifier) ? statement.moduleSpecifier.text : "";
3052
+ return ts19.isStringLiteral(statement.moduleSpecifier) ? statement.moduleSpecifier.text : "";
2899
3053
  }
2900
3054
  function isVendorSpecifier(specifier) {
2901
3055
  if (specifier === "" || specifier.startsWith(".") || specifier.startsWith("/"))
@@ -2908,13 +3062,13 @@ function isVendorSpecifier(specifier) {
2908
3062
  }
2909
3063
  function getAccessRoot(node) {
2910
3064
  let current = node;
2911
- while (ts18.isPropertyAccessExpression(current))
3065
+ while (ts19.isPropertyAccessExpression(current))
2912
3066
  current = current.expression;
2913
- return ts18.isIdentifier(current) ? current.text : "";
3067
+ return ts19.isIdentifier(current) ? current.text : "";
2914
3068
  }
2915
3069
 
2916
3070
  // pkgs/@akanjs/devkit/testOnlyExportScanner.ts
2917
- import ts19 from "typescript";
3071
+ import ts20 from "typescript";
2918
3072
 
2919
3073
  class TestOnlyExportScanner {
2920
3074
  static rule = "akan.global.test-only-export";
@@ -2965,9 +3119,9 @@ class TestOnlyExportScanner {
2965
3119
  static #identifierLinesOf(sourceFile) {
2966
3120
  const lines = new Map;
2967
3121
  const visit = (node) => {
2968
- if (ts19.isIdentifier(node) && !lines.has(node.text))
3122
+ if (ts20.isIdentifier(node) && !lines.has(node.text))
2969
3123
  lines.set(node.text, sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1);
2970
- ts19.forEachChild(node, visit);
3124
+ ts20.forEachChild(node, visit);
2971
3125
  };
2972
3126
  visit(sourceFile);
2973
3127
  return lines;
@@ -2984,15 +3138,15 @@ class TestOnlyExportScanner {
2984
3138
  });
2985
3139
  }
2986
3140
  static #isNamedExport(statement) {
2987
- if (!ts19.canHaveModifiers(statement))
3141
+ if (!ts20.canHaveModifiers(statement))
2988
3142
  return false;
2989
- const modifiers = ts19.getModifiers(statement) ?? [];
2990
- return modifiers.some((modifier) => modifier.kind === ts19.SyntaxKind.ExportKeyword) && !modifiers.some((modifier) => modifier.kind === ts19.SyntaxKind.DefaultKeyword);
3143
+ const modifiers = ts20.getModifiers(statement) ?? [];
3144
+ return modifiers.some((modifier) => modifier.kind === ts20.SyntaxKind.ExportKeyword) && !modifiers.some((modifier) => modifier.kind === ts20.SyntaxKind.DefaultKeyword);
2991
3145
  }
2992
3146
  static #declaredNamesOf(statement) {
2993
- if (ts19.isVariableStatement(statement))
2994
- return statement.declarationList.declarations.map((declaration) => declaration.name).filter((name) => ts19.isIdentifier(name));
2995
- if (ts19.isFunctionDeclaration(statement) || ts19.isClassDeclaration(statement) || ts19.isInterfaceDeclaration(statement) || ts19.isTypeAliasDeclaration(statement) || ts19.isEnumDeclaration(statement))
3147
+ if (ts20.isVariableStatement(statement))
3148
+ return statement.declarationList.declarations.map((declaration) => declaration.name).filter((name) => ts20.isIdentifier(name));
3149
+ if (ts20.isFunctionDeclaration(statement) || ts20.isClassDeclaration(statement) || ts20.isInterfaceDeclaration(statement) || ts20.isTypeAliasDeclaration(statement) || ts20.isEnumDeclaration(statement))
2996
3150
  return statement.name ? [statement.name] : [];
2997
3151
  return [];
2998
3152
  }
@@ -3002,10 +3156,10 @@ class TestOnlyExportScanner {
3002
3156
  const visit = (node) => {
3003
3157
  if (used || ownStatements.has(node))
3004
3158
  return;
3005
- if (ts19.isIdentifier(node) && node.text === name)
3159
+ if (ts20.isIdentifier(node) && node.text === name)
3006
3160
  used = true;
3007
3161
  else
3008
- ts19.forEachChild(node, visit);
3162
+ ts20.forEachChild(node, visit);
3009
3163
  };
3010
3164
  visit(sourceFile);
3011
3165
  return used;
@@ -3153,7 +3307,7 @@ class AkanQualityScanner {
3153
3307
  file,
3154
3308
  absolutePath,
3155
3309
  content,
3156
- sourceFile: ts20.createSourceFile(file, content, ts20.ScriptTarget.Latest, true, getScriptKind(file))
3310
+ sourceFile: ts21.createSourceFile(file, content, ts21.ScriptTarget.Latest, true, getScriptKind(file))
3157
3311
  };
3158
3312
  }
3159
3313
  async#readTextFile(workspaceRoot, file) {
@@ -3352,13 +3506,13 @@ function getExportedFunctionLikes(sourceFile) {
3352
3506
  duplicateNameExempt: nameExempt || isConventionDuplicateNameExempt(sourceFile.file, isEnumClass)
3353
3507
  });
3354
3508
  for (const statement of sourceFile.sourceFile.statements) {
3355
- if (ts20.isFunctionDeclaration(statement) && statement.name && isExported(statement))
3509
+ if (ts21.isFunctionDeclaration(statement) && statement.name && isExported(statement))
3356
3510
  add(statement.name.text, "function", statement, statement.body);
3357
- if (ts20.isClassDeclaration(statement) && statement.name && isExported(statement))
3511
+ if (ts21.isClassDeclaration(statement) && statement.name && isExported(statement))
3358
3512
  add(statement.name.text, "class", statement, statement, isEnumClassStatement(sourceFile.sourceFile, statement));
3359
- if (ts20.isVariableStatement(statement) && isExported(statement)) {
3513
+ if (ts21.isVariableStatement(statement) && isExported(statement)) {
3360
3514
  for (const declaration of statement.declarationList.declarations) {
3361
- if (!ts20.isIdentifier(declaration.name) || !isFunctionLikeInitializer(declaration.initializer))
3515
+ if (!ts21.isIdentifier(declaration.name) || !isFunctionLikeInitializer(declaration.initializer))
3362
3516
  continue;
3363
3517
  add(declaration.name.text, "function-variable", declaration, declaration.initializer);
3364
3518
  }
@@ -3386,14 +3540,14 @@ function isConventionDuplicateNameExempt(file, isEnumClass) {
3386
3540
  return false;
3387
3541
  }
3388
3542
  function isEnumClassStatement(sourceFile, statement) {
3389
- if (!ts20.isClassDeclaration(statement))
3543
+ if (!ts21.isClassDeclaration(statement))
3390
3544
  return false;
3391
- const heritageClause = statement.heritageClauses?.find((clause) => clause.token === ts20.SyntaxKind.ExtendsKeyword);
3545
+ const heritageClause = statement.heritageClauses?.find((clause) => clause.token === ts21.SyntaxKind.ExtendsKeyword);
3392
3546
  const expression = heritageClause?.types[0]?.expression;
3393
3547
  return !!expression && expression.getText(sourceFile).startsWith("enumOf(");
3394
3548
  }
3395
3549
  function getExportedClassNames(sourceFile) {
3396
- return sourceFile.statements.filter((statement) => ts20.isClassDeclaration(statement)).filter((statement) => isExported(statement)).map((statement) => statement.name?.text).filter((name) => !!name);
3550
+ return sourceFile.statements.filter((statement) => ts21.isClassDeclaration(statement)).filter((statement) => isExported(statement)).map((statement) => statement.name?.text).filter((name) => !!name);
3397
3551
  }
3398
3552
  function isComponentDeclarationFile(file) {
3399
3553
  if (!file.endsWith(".tsx"))
@@ -3409,7 +3563,7 @@ function isComponentDeclarationFile(file) {
3409
3563
  function getComponentFileDeclarations(sourceFile) {
3410
3564
  const reExportedNames = new Set;
3411
3565
  for (const statement of sourceFile.statements) {
3412
- if (ts20.isExportDeclaration(statement) && statement.exportClause && ts20.isNamedExports(statement.exportClause)) {
3566
+ if (ts21.isExportDeclaration(statement) && statement.exportClause && ts21.isNamedExports(statement.exportClause)) {
3413
3567
  for (const element of statement.exportClause.elements)
3414
3568
  reExportedNames.add((element.propertyName ?? element.name).text);
3415
3569
  }
@@ -3419,19 +3573,19 @@ function getComponentFileDeclarations(sourceFile) {
3419
3573
  const isDefaultExport = isDefaultExportStatement(statement);
3420
3574
  const inlineExported = isExported(statement);
3421
3575
  const add = (name, kind, line) => declarations.push({ name, kind, line, exported: inlineExported || reExportedNames.has(name), isDefaultExport });
3422
- if (ts20.isInterfaceDeclaration(statement))
3576
+ if (ts21.isInterfaceDeclaration(statement))
3423
3577
  add(statement.name.text, "interface", getLine(sourceFile, statement));
3424
- else if (ts20.isTypeAliasDeclaration(statement))
3578
+ else if (ts21.isTypeAliasDeclaration(statement))
3425
3579
  add(statement.name.text, "type", getLine(sourceFile, statement));
3426
- else if (ts20.isEnumDeclaration(statement))
3580
+ else if (ts21.isEnumDeclaration(statement))
3427
3581
  add(statement.name.text, "enum", getLine(sourceFile, statement));
3428
- else if (ts20.isFunctionDeclaration(statement) && statement.name)
3582
+ else if (ts21.isFunctionDeclaration(statement) && statement.name)
3429
3583
  add(statement.name.text, "function", getLine(sourceFile, statement));
3430
- else if (ts20.isClassDeclaration(statement) && statement.name)
3584
+ else if (ts21.isClassDeclaration(statement) && statement.name)
3431
3585
  add(statement.name.text, "class", getLine(sourceFile, statement));
3432
- else if (ts20.isVariableStatement(statement)) {
3586
+ else if (ts21.isVariableStatement(statement)) {
3433
3587
  for (const declaration of statement.declarationList.declarations) {
3434
- if (!ts20.isIdentifier(declaration.name))
3588
+ if (!ts21.isIdentifier(declaration.name))
3435
3589
  continue;
3436
3590
  const kind = isFunctionLikeInitializer(declaration.initializer) ? "function" : "variable";
3437
3591
  add(declaration.name.text, kind, getLine(sourceFile, declaration));
@@ -3443,15 +3597,15 @@ function getComponentFileDeclarations(sourceFile) {
3443
3597
  function getCompoundComponentNames(sourceFile) {
3444
3598
  const names = new Set;
3445
3599
  for (const statement of sourceFile.statements) {
3446
- if (!ts20.isExpressionStatement(statement))
3600
+ if (!ts21.isExpressionStatement(statement))
3447
3601
  continue;
3448
3602
  const { expression } = statement;
3449
- if (!ts20.isBinaryExpression(expression) || expression.operatorToken.kind !== ts20.SyntaxKind.EqualsToken)
3603
+ if (!ts21.isBinaryExpression(expression) || expression.operatorToken.kind !== ts21.SyntaxKind.EqualsToken)
3450
3604
  continue;
3451
- if (!ts20.isPropertyAccessExpression(expression.left) || !isPascalCaseName(expression.left.name.text))
3605
+ if (!ts21.isPropertyAccessExpression(expression.left) || !isPascalCaseName(expression.left.name.text))
3452
3606
  continue;
3453
3607
  names.add(expression.left.name.text);
3454
- if (ts20.isIdentifier(expression.right) && isPascalCaseName(expression.right.text))
3608
+ if (ts21.isIdentifier(expression.right) && isPascalCaseName(expression.right.text))
3455
3609
  names.add(expression.right.text);
3456
3610
  }
3457
3611
  return names;
@@ -3471,11 +3625,11 @@ function isPascalCaseName(name) {
3471
3625
  return /^[A-Z]/.test(name) && !/^[A-Z0-9_]+$/.test(name);
3472
3626
  }
3473
3627
  function isDefaultExportStatement(statement) {
3474
- if (ts20.isExportAssignment(statement))
3628
+ if (ts21.isExportAssignment(statement))
3475
3629
  return !statement.isExportEquals;
3476
- if (!ts20.canHaveModifiers(statement))
3630
+ if (!ts21.canHaveModifiers(statement))
3477
3631
  return false;
3478
- return !!ts20.getModifiers(statement)?.some((modifier) => modifier.kind === ts20.SyntaxKind.DefaultKeyword);
3632
+ return !!ts21.getModifiers(statement)?.some((modifier) => modifier.kind === ts21.SyntaxKind.DefaultKeyword);
3479
3633
  }
3480
3634
  function getBangCommentWarnings(sourceFile) {
3481
3635
  if (!isClientReachableFile(sourceFile.file))
@@ -3511,11 +3665,11 @@ function getGlobalMutationWarnings(sourceFile) {
3511
3665
  const warnings = [];
3512
3666
  for (const statement of sourceFile.sourceFile.statements) {
3513
3667
  const warn = (rule, message) => warnings.push(fileWarning(rule, "file", sourceFile.file, message, getLine(sourceFile.sourceFile, statement)));
3514
- if (ts20.isModuleDeclaration(statement) && statement.name.getText(sourceFile.sourceFile) === "global")
3668
+ if (ts21.isModuleDeclaration(statement) && statement.name.getText(sourceFile.sourceFile) === "global")
3515
3669
  warn("akan.file.global-declaration", "Global declarations require an explicit low-level integration allowlist.");
3516
- if (ts20.isInterfaceDeclaration(statement) && statement.name.text === "Window")
3670
+ if (ts21.isInterfaceDeclaration(statement) && statement.name.text === "Window")
3517
3671
  warn("akan.file.window-augmentation", "Window augmentation should be isolated to approved browser integration files.");
3518
- if (ts20.isExpressionStatement(statement) && statement.expression.getText(sourceFile.sourceFile).includes(".prototype."))
3672
+ if (ts21.isExpressionStatement(statement) && statement.expression.getText(sourceFile.sourceFile).includes(".prototype."))
3519
3673
  warn("akan.file.prototype-mutation", "Prototype mutation should be avoided or isolated to approved low-level integration files.");
3520
3674
  }
3521
3675
  return warnings;
@@ -3532,19 +3686,19 @@ function getTopLevelDeclaration(sourceFile, statement) {
3532
3686
  exported: isExported(statement),
3533
3687
  node: statement
3534
3688
  });
3535
- if (ts20.isClassDeclaration(statement) && statement.name)
3689
+ if (ts21.isClassDeclaration(statement) && statement.name)
3536
3690
  return [declared(statement.name.text, "class")];
3537
- if (ts20.isFunctionDeclaration(statement) && statement.name)
3691
+ if (ts21.isFunctionDeclaration(statement) && statement.name)
3538
3692
  return [declared(statement.name.text, "function")];
3539
- if (ts20.isInterfaceDeclaration(statement))
3693
+ if (ts21.isInterfaceDeclaration(statement))
3540
3694
  return [declared(statement.name.text, "interface")];
3541
- if (ts20.isTypeAliasDeclaration(statement))
3695
+ if (ts21.isTypeAliasDeclaration(statement))
3542
3696
  return [declared(statement.name.text, "type")];
3543
- if (ts20.isEnumDeclaration(statement))
3697
+ if (ts21.isEnumDeclaration(statement))
3544
3698
  return [declared(statement.name.text, "enum")];
3545
- if (ts20.isVariableStatement(statement))
3546
- return statement.declarationList.declarations.filter((declaration) => ts20.isIdentifier(declaration.name)).map((declaration) => declared(declaration.name.text, "variable", getLine(sourceFile, declaration)));
3547
- if (ts20.isExportDeclaration(statement))
3699
+ if (ts21.isVariableStatement(statement))
3700
+ return statement.declarationList.declarations.filter((declaration) => ts21.isIdentifier(declaration.name)).map((declaration) => declared(declaration.name.text, "variable", getLine(sourceFile, declaration)));
3701
+ if (ts21.isExportDeclaration(statement))
3548
3702
  return [{ name: "export declaration", kind: "export", line, exported: true, node: statement }];
3549
3703
  return [];
3550
3704
  }
@@ -3632,13 +3786,13 @@ function getModuleInfo(file) {
3632
3786
  return { moduleName, fileName, kind: "database" };
3633
3787
  }
3634
3788
  function isExportedConst(declaration) {
3635
- return declaration.exported && ts20.isVariableStatement(declaration.node) && (declaration.node.declarationList.flags & ts20.NodeFlags.Const) !== 0;
3789
+ return declaration.exported && ts21.isVariableStatement(declaration.node) && (declaration.node.declarationList.flags & ts21.NodeFlags.Const) !== 0;
3636
3790
  }
3637
3791
  function isExported(node) {
3638
- return !!(ts20.getCombinedModifierFlags(node) & ts20.ModifierFlags.Export);
3792
+ return !!(ts21.getCombinedModifierFlags(node) & ts21.ModifierFlags.Export);
3639
3793
  }
3640
3794
  function isFunctionLikeInitializer(node) {
3641
- return !!node && (ts20.isArrowFunction(node) || ts20.isFunctionExpression(node));
3795
+ return !!node && (ts21.isArrowFunction(node) || ts21.isFunctionExpression(node));
3642
3796
  }
3643
3797
  function getBodyFingerprint(sourceFile, node) {
3644
3798
  if (!node)
@@ -3660,7 +3814,7 @@ async function isDirectory(absolutePath) {
3660
3814
  }
3661
3815
  }
3662
3816
  function getScriptKind(file) {
3663
- return file.endsWith(".tsx") ? ts20.ScriptKind.TSX : ts20.ScriptKind.TS;
3817
+ return file.endsWith(".tsx") ? ts21.ScriptKind.TSX : ts21.ScriptKind.TS;
3664
3818
  }
3665
3819
  function getLine(sourceFile, node) {
3666
3820
  return sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1;