@nifrajs/cli 5.17.0 → 5.18.0

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 (178) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/dist/check-diagnostics.d.ts +7 -0
  3. package/dist/check-diagnostics.d.ts.map +1 -1
  4. package/dist/check-diagnostics.js +3 -0
  5. package/dist/check-diagnostics.js.map +1 -1
  6. package/dist/check-scan-sql.d.ts +95 -0
  7. package/dist/check-scan-sql.d.ts.map +1 -0
  8. package/dist/check-scan-sql.js +1190 -0
  9. package/dist/check-scan-sql.js.map +1 -0
  10. package/dist/check-scan.d.ts +5 -93
  11. package/dist/check-scan.d.ts.map +1 -1
  12. package/dist/check-scan.js +20 -1207
  13. package/dist/check-scan.js.map +1 -1
  14. package/dist/check.d.ts.map +1 -1
  15. package/dist/check.js +9 -0
  16. package/dist/check.js.map +1 -1
  17. package/dist/cli.d.ts +2 -6
  18. package/dist/cli.d.ts.map +1 -1
  19. package/dist/cli.js +249 -80
  20. package/dist/cli.js.map +1 -1
  21. package/dist/command-catalog.d.ts +3 -0
  22. package/dist/command-catalog.d.ts.map +1 -1
  23. package/dist/command-catalog.js +18 -4
  24. package/dist/command-catalog.js.map +1 -1
  25. package/dist/frontend-guidance.js +1 -1
  26. package/dist/frontend-guidance.js.map +1 -1
  27. package/dist/internal/a11y-element.d.ts +33 -0
  28. package/dist/internal/a11y-element.d.ts.map +1 -0
  29. package/dist/internal/a11y-element.js +124 -0
  30. package/dist/internal/a11y-element.js.map +1 -0
  31. package/dist/internal/a11y-jsx.d.ts +12 -0
  32. package/dist/internal/a11y-jsx.d.ts.map +1 -0
  33. package/dist/internal/a11y-jsx.js +42 -0
  34. package/dist/internal/a11y-jsx.js.map +1 -0
  35. package/dist/internal/a11y-template.d.ts +11 -0
  36. package/dist/internal/a11y-template.d.ts.map +1 -0
  37. package/dist/internal/a11y-template.js +56 -0
  38. package/dist/internal/a11y-template.js.map +1 -0
  39. package/dist/internal/aria-data.d.ts +23 -0
  40. package/dist/internal/aria-data.d.ts.map +1 -0
  41. package/dist/internal/aria-data.js +220 -0
  42. package/dist/internal/aria-data.js.map +1 -0
  43. package/dist/internal/edit-distance.d.ts +3 -0
  44. package/dist/internal/edit-distance.d.ts.map +1 -0
  45. package/dist/internal/edit-distance.js +12 -0
  46. package/dist/internal/edit-distance.js.map +1 -0
  47. package/dist/internal/imported-as.d.ts +10 -0
  48. package/dist/internal/imported-as.d.ts.map +1 -0
  49. package/dist/internal/imported-as.js +23 -0
  50. package/dist/internal/imported-as.js.map +1 -0
  51. package/dist/internal/source-facts.d.ts +3 -0
  52. package/dist/internal/source-facts.d.ts.map +1 -1
  53. package/dist/internal/source-facts.js +2 -0
  54. package/dist/internal/source-facts.js.map +1 -1
  55. package/dist/internal/template-markup.d.ts +58 -0
  56. package/dist/internal/template-markup.d.ts.map +1 -0
  57. package/dist/internal/template-markup.js +221 -0
  58. package/dist/internal/template-markup.js.map +1 -0
  59. package/dist/internal/typescript-import.d.ts.map +1 -1
  60. package/dist/internal/typescript-import.js +11 -0
  61. package/dist/internal/typescript-import.js.map +1 -1
  62. package/dist/mcp-exec.d.ts.map +1 -1
  63. package/dist/mcp-exec.js +37 -23
  64. package/dist/mcp-exec.js.map +1 -1
  65. package/dist/mcp-http.js +1 -1
  66. package/dist/mcp-io.d.ts.map +1 -1
  67. package/dist/mcp-io.js +5 -3
  68. package/dist/mcp-io.js.map +1 -1
  69. package/dist/mcp-root.js +1 -1
  70. package/dist/mcp-root.js.map +1 -1
  71. package/dist/mcp-ws.d.ts.map +1 -1
  72. package/dist/mcp-ws.js +3 -2
  73. package/dist/mcp-ws.js.map +1 -1
  74. package/dist/migrate-layout-config.d.ts +63 -0
  75. package/dist/migrate-layout-config.d.ts.map +1 -0
  76. package/dist/migrate-layout-config.js +507 -0
  77. package/dist/migrate-layout-config.js.map +1 -0
  78. package/dist/migrate-layout-split.d.ts +46 -0
  79. package/dist/migrate-layout-split.d.ts.map +1 -0
  80. package/dist/migrate-layout-split.js +687 -0
  81. package/dist/migrate-layout-split.js.map +1 -0
  82. package/dist/migrate-layout.d.ts +4 -24
  83. package/dist/migrate-layout.d.ts.map +1 -1
  84. package/dist/migrate-layout.js +8 -1183
  85. package/dist/migrate-layout.js.map +1 -1
  86. package/dist/output-schemas.d.ts.map +1 -1
  87. package/dist/output-schemas.js +78 -10
  88. package/dist/output-schemas.js.map +1 -1
  89. package/dist/recipes/5.18.0.d.ts +9 -0
  90. package/dist/recipes/5.18.0.d.ts.map +1 -0
  91. package/dist/recipes/5.18.0.js +56 -0
  92. package/dist/recipes/5.18.0.js.map +1 -0
  93. package/dist/recipes/index.d.ts.map +1 -1
  94. package/dist/recipes/index.js +2 -0
  95. package/dist/recipes/index.js.map +1 -1
  96. package/dist/review.d.ts.map +1 -1
  97. package/dist/review.js +6 -0
  98. package/dist/review.js.map +1 -1
  99. package/dist/rules/a11y.d.ts +5 -0
  100. package/dist/rules/a11y.d.ts.map +1 -0
  101. package/dist/rules/a11y.js +78 -0
  102. package/dist/rules/a11y.js.map +1 -0
  103. package/dist/rules/codes.d.ts +6 -0
  104. package/dist/rules/codes.d.ts.map +1 -1
  105. package/dist/rules/codes.js +6 -0
  106. package/dist/rules/codes.js.map +1 -1
  107. package/dist/rules/comment-markers.js +1 -1
  108. package/dist/rules/comment-markers.js.map +1 -1
  109. package/dist/rules/explanations.d.ts.map +1 -1
  110. package/dist/rules/explanations.js +30 -0
  111. package/dist/rules/explanations.js.map +1 -1
  112. package/dist/rules/host-exposure.d.ts +23 -0
  113. package/dist/rules/host-exposure.d.ts.map +1 -0
  114. package/dist/rules/host-exposure.js +380 -0
  115. package/dist/rules/host-exposure.js.map +1 -0
  116. package/dist/rules/internal-links.d.ts.map +1 -1
  117. package/dist/rules/internal-links.js +16 -141
  118. package/dist/rules/internal-links.js.map +1 -1
  119. package/dist/rules/islands.d.ts +54 -0
  120. package/dist/rules/islands.d.ts.map +1 -1
  121. package/dist/rules/islands.js +577 -80
  122. package/dist/rules/islands.js.map +1 -1
  123. package/dist/rules/security.d.ts +1 -0
  124. package/dist/rules/security.d.ts.map +1 -1
  125. package/dist/rules/security.js +34 -7
  126. package/dist/rules/security.js.map +1 -1
  127. package/dist/runtime-differences.js +3 -3
  128. package/dist/runtime-differences.js.map +1 -1
  129. package/dist/scaffold.d.ts +1 -1
  130. package/dist/scaffold.d.ts.map +1 -1
  131. package/dist/scaffold.js +2 -2
  132. package/dist/scaffold.js.map +1 -1
  133. package/dist/source-rewrites.d.ts.map +1 -1
  134. package/dist/source-rewrites.js +2 -19
  135. package/dist/source-rewrites.js.map +1 -1
  136. package/docs/examples.json +4 -4
  137. package/docs/llms-full.txt +422 -42
  138. package/docs/types.json +466 -56
  139. package/package.json +12 -12
  140. package/src/check-diagnostics.ts +11 -0
  141. package/src/check-scan-sql.ts +1746 -0
  142. package/src/check-scan.ts +34 -1754
  143. package/src/check.ts +10 -1
  144. package/src/cli.ts +258 -98
  145. package/src/command-catalog.ts +21 -4
  146. package/src/frontend-guidance.ts +1 -1
  147. package/src/internal/a11y-element.ts +227 -0
  148. package/src/internal/a11y-jsx.ts +54 -0
  149. package/src/internal/a11y-template.ts +74 -0
  150. package/src/internal/aria-data.ts +242 -0
  151. package/src/internal/edit-distance.ts +16 -0
  152. package/src/internal/imported-as.ts +30 -0
  153. package/src/internal/source-facts.ts +4 -0
  154. package/src/internal/template-markup.ts +270 -0
  155. package/src/internal/typescript-import.ts +15 -0
  156. package/src/mcp-exec.ts +43 -22
  157. package/src/mcp-http.ts +1 -1
  158. package/src/mcp-io.ts +5 -3
  159. package/src/mcp-root.ts +1 -1
  160. package/src/mcp-ws.ts +3 -2
  161. package/src/migrate-layout-config.ts +615 -0
  162. package/src/migrate-layout-split.ts +870 -0
  163. package/src/migrate-layout.ts +37 -1468
  164. package/src/output-schemas.ts +85 -17
  165. package/src/recipes/5.18.0.ts +63 -0
  166. package/src/recipes/index.ts +2 -0
  167. package/src/review.ts +6 -0
  168. package/src/rules/a11y.ts +119 -0
  169. package/src/rules/codes.ts +6 -0
  170. package/src/rules/comment-markers.ts +2 -2
  171. package/src/rules/explanations.ts +30 -0
  172. package/src/rules/host-exposure.ts +531 -0
  173. package/src/rules/internal-links.ts +21 -154
  174. package/src/rules/islands.ts +698 -86
  175. package/src/rules/security.ts +48 -7
  176. package/src/runtime-differences.ts +3 -3
  177. package/src/scaffold.ts +3 -3
  178. package/src/source-rewrites.ts +2 -15
package/src/mcp-exec.ts CHANGED
@@ -781,7 +781,7 @@ export async function spawnChild(
781
781
  } catch {
782
782
  return `${label} input is not serializable.`
783
783
  }
784
- if (new TextEncoder().encode(encodedInput).byteLength > CHILD_INPUT_MAX_BYTES)
784
+ if (Buffer.byteLength(encodedInput, "utf8") > CHILD_INPUT_MAX_BYTES)
785
785
  return `${label} input exceeded ${CHILD_INPUT_MAX_BYTES} bytes.`
786
786
  if (signal?.aborted) return `${label} cancelled${cancellationSuffix(signal)}.`
787
787
  const proc = Bun.spawn([process.execPath, childPath(child), cwd], {
@@ -851,9 +851,11 @@ const WARM_RUN_SOURCE = /\.(?:[cm]?[jt]sx?|json)$/
851
851
  const WARM_RUN_SKIPPED_DIR = /^(?:\..*|node_modules|dist(?:-[a-z0-9]+)?|build|coverage)$/
852
852
  const WARM_RUN_EXTRA_FILES = ["bun.lock", "bun.lockb"] as const
853
853
  const MAX_WARM_PENDING = 64
854
+ const WARM_RUN_STAT_CONCURRENCY = 32
854
855
 
855
856
  async function warmRunFingerprint(cwd: string): Promise<string> {
856
857
  const parts: string[] = []
858
+ const pending = [{ path: "", directory: true }]
857
859
  const walk = async (dir: string): Promise<void> => {
858
860
  let entries: Dirent[]
859
861
  try {
@@ -863,23 +865,36 @@ async function warmRunFingerprint(cwd: string): Promise<string> {
863
865
  }
864
866
  for (const entry of entries) {
865
867
  const rel = dir === "" ? entry.name : `${dir}/${entry.name}`
866
- if (entry.isDirectory()) {
867
- if (!WARM_RUN_SKIPPED_DIR.test(entry.name)) await walk(rel)
868
+ const directory = entry.isDirectory()
869
+ if (
870
+ directory
871
+ ? WARM_RUN_SKIPPED_DIR.test(entry.name)
872
+ : entry.name.startsWith(".") || !WARM_RUN_SOURCE.test(entry.name)
873
+ )
868
874
  continue
869
- }
870
- if (entry.name.startsWith(".") || !WARM_RUN_SOURCE.test(entry.name)) continue
871
- try {
872
- const s = await stat(resolve(cwd, rel))
873
- if (s.isFile()) parts.push(`${rel}:${s.mtimeMs}:${s.size}`)
874
- } catch {
875
- // A file can disappear while an agent is editing. The next call will rescan the settled tree.
876
- }
875
+ pending.push({ path: rel, directory })
877
876
  }
878
877
  }
879
- await walk("")
880
- for (const rel of WARM_RUN_EXTRA_FILES) {
881
- parts.push(`${rel}:${await fileFingerprint(resolve(cwd, rel))}`)
878
+ // Share a bound across the whole tree so a wide workspace cannot enqueue every stat at once.
879
+ for (let start = 0; start < pending.length; ) {
880
+ const batch = pending.slice(start, start + WARM_RUN_STAT_CONCURRENCY)
881
+ start += batch.length
882
+ await Promise.all(
883
+ batch.map(async ({ path, directory }) => {
884
+ if (directory) return walk(path)
885
+ try {
886
+ const info = await stat(resolve(cwd, path))
887
+ if (info.isFile()) parts.push(`${path}:${info.mtimeMs}:${info.size}`)
888
+ } catch {
889
+ // A file can disappear while an agent is editing. The next call scans the settled tree.
890
+ }
891
+ }),
892
+ )
882
893
  }
894
+ const extra = await Promise.all(
895
+ WARM_RUN_EXTRA_FILES.map(async (rel) => `${rel}:${await fileFingerprint(resolve(cwd, rel))}`),
896
+ )
897
+ parts.push(...extra)
883
898
  return cacheToken(parts.sort().join("|"))
884
899
  }
885
900
 
@@ -983,7 +998,7 @@ export class WarmWorker {
983
998
  } catch {
984
999
  throw new Error(`warm ${this.label} input is not serializable`)
985
1000
  }
986
- if (new TextEncoder().encode(encodedInput).byteLength > CHILD_INPUT_MAX_BYTES)
1001
+ if (Buffer.byteLength(encodedInput, "utf8") > CHILD_INPUT_MAX_BYTES)
987
1002
  throw new Error(`warm ${this.label} input exceeded ${CHILD_INPUT_MAX_BYTES} bytes`)
988
1003
  if (signal?.aborted) return `${this.label} cancelled${cancellationSuffix(signal)}.`
989
1004
  return new Promise((resolve, reject) => {
@@ -1046,7 +1061,7 @@ export class WarmWorker {
1046
1061
  }
1047
1062
  const text = decoder.decode(value, { stream: true })
1048
1063
  this.stdoutBuffer += text
1049
- this.stdoutBufferBytes += new TextEncoder().encode(text).byteLength
1064
+ this.stdoutBufferBytes += Buffer.byteLength(text, "utf8")
1050
1065
  if (this.stdoutBufferBytes > CHILD_OUTPUT_MAX_BYTES) {
1051
1066
  this.stderrBuffer = boundedAppend(
1052
1067
  this.stderrBuffer,
@@ -1055,14 +1070,20 @@ export class WarmWorker {
1055
1070
  this.stop()
1056
1071
  return
1057
1072
  }
1058
- let nl = this.stdoutBuffer.indexOf("\n")
1073
+ let start = 0
1074
+ let nl = this.stdoutBuffer.indexOf("\n", start)
1059
1075
  while (nl !== -1) {
1060
- const line = this.stdoutBuffer.slice(0, nl).trim()
1061
- this.stdoutBuffer = this.stdoutBuffer.slice(nl + 1)
1062
- this.stdoutBufferBytes = new TextEncoder().encode(this.stdoutBuffer).byteLength
1063
- nl = this.stdoutBuffer.indexOf("\n")
1076
+ const rawLine = this.stdoutBuffer.slice(start, nl)
1077
+ start = nl + 1
1078
+ this.stdoutBufferBytes -= Buffer.byteLength(rawLine, "utf8") + 1
1079
+ const line = rawLine.trim()
1080
+ nl = this.stdoutBuffer.indexOf("\n", start)
1064
1081
  if (line !== "") this.handleLine(line)
1065
1082
  }
1083
+ if (start > 0) {
1084
+ this.stdoutBuffer = this.stdoutBuffer.slice(start)
1085
+ if (this.stdoutBuffer.length === 0) this.stdoutBufferBytes = 0
1086
+ }
1066
1087
  }
1067
1088
  }
1068
1089
 
@@ -1122,7 +1143,7 @@ export class WarmWorker {
1122
1143
  this.stop()
1123
1144
  return
1124
1145
  }
1125
- if (new TextEncoder().encode(output).byteLength > CHILD_OUTPUT_MAX_BYTES) {
1146
+ if (Buffer.byteLength(output, "utf8") > CHILD_OUTPUT_MAX_BYTES) {
1126
1147
  this.pending.delete(response.id)
1127
1148
  pending.cleanup()
1128
1149
  pending.reject(new Error(`warm ${this.label} worker response exceeded the size limit`))
package/src/mcp-http.ts CHANGED
@@ -30,7 +30,7 @@ export { docsTools } from "./mcp-docs-tools.ts"
30
30
  export type { TypeEntry } from "./types-search.ts"
31
31
 
32
32
  // Kept in lockstep with packages/cli/package.json by check:publish's version-consistency gate.
33
- const VERSION = "5.17.0"
33
+ const VERSION = "5.18.0"
34
34
  const SERVER_INFO = { name: "nifra-docs", version: VERSION }
35
35
  // Derive the GET/health tool list from the tools actually served, so the line can never drift from them.
36
36
  const docsHealth = (tools: McpTool[]): string =>
package/src/mcp-io.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  * these limits and stream readers so an untrusted local endpoint or child process cannot exhaust MCP.
6
6
  */
7
7
 
8
+ import { Buffer } from "node:buffer"
8
9
  import { isRecord } from "./internal/record.ts"
9
10
 
10
11
  export const CHILD_TIMEOUT_MS = 30_000
@@ -12,6 +13,7 @@ export const CHILD_TIMEOUT_MS = 30_000
12
13
  export const CHILD_OUTPUT_MAX_BYTES = 1_048_576
13
14
  /** Maximum serialized request sent to a project subprocess or warm worker. */
14
15
  export const CHILD_INPUT_MAX_BYTES = 4 * 1024 * 1024
16
+ const UTF8_DECODER = new TextDecoder()
15
17
 
16
18
  /** Local dev-tool reads are intentionally bounded: MCP runs in an agent process and must not hang on or
17
19
  * buffer an unrelated loopback service just because a caller supplied its port. */
@@ -207,7 +209,7 @@ export async function readBoundedResponse(
207
209
  bytes.set(chunk, offset)
208
210
  offset += chunk.byteLength
209
211
  }
210
- return new TextDecoder().decode(bytes)
212
+ return UTF8_DECODER.decode(bytes)
211
213
  }
212
214
 
213
215
  export const notNifraResponse = (service: string): string =>
@@ -242,7 +244,7 @@ function decodeLine(chunks: readonly Uint8Array[], totalBytes: number): string {
242
244
  bytes.set(chunk, offset)
243
245
  offset += chunk.byteLength
244
246
  }
245
- return new TextDecoder().decode(bytes)
247
+ return UTF8_DECODER.decode(bytes)
246
248
  }
247
249
 
248
250
  /**
@@ -301,7 +303,7 @@ export function serializeBoundedJson(
301
303
  } catch {
302
304
  return undefined
303
305
  }
304
- if (text === undefined || new TextEncoder().encode(text).byteLength > maxBytes) return undefined
306
+ if (text === undefined || Buffer.byteLength(text, "utf8") > maxBytes) return undefined
305
307
  return text
306
308
  }
307
309
 
package/src/mcp-root.ts CHANGED
@@ -145,7 +145,7 @@ async function workspaceMatches(
145
145
  const queue: { readonly path: string; readonly depth: number }[] = [
146
146
  { path: prefix.join("/"), depth: prefix.length },
147
147
  ]
148
- for (let next = queue.shift(); next !== undefined; next = queue.shift()) {
148
+ for (const next of queue) {
149
149
  if (budget.directories <= 0) break
150
150
  budget.directories -= 1
151
151
  const absolute = join(dir, next.path)
package/src/mcp-ws.ts CHANGED
@@ -16,6 +16,7 @@ const MAX_MESSAGES = 50
16
16
  const MAX_MESSAGE_BYTES = 64 * 1024
17
17
  const MAX_PATH_LENGTH = 2_048
18
18
  const ENCODER = new TextEncoder()
19
+ const DECODER = new TextDecoder()
19
20
 
20
21
  interface RunningServerLike {
21
22
  readonly port: number
@@ -153,9 +154,9 @@ function normalizeInput(args: unknown): NormalizedInput | { error: string; path:
153
154
 
154
155
  async function dataToString(data: unknown): Promise<string> {
155
156
  if (typeof data === "string") return data
156
- if (data instanceof ArrayBuffer) return new TextDecoder().decode(data)
157
+ if (data instanceof ArrayBuffer) return DECODER.decode(data)
157
158
  if (ArrayBuffer.isView(data)) {
158
- return new TextDecoder().decode(new Uint8Array(data.buffer, data.byteOffset, data.byteLength))
159
+ return DECODER.decode(new Uint8Array(data.buffer, data.byteOffset, data.byteLength))
159
160
  }
160
161
  if (typeof Blob !== "undefined" && data instanceof Blob) return data.text()
161
162
  return String(data)