@nifrajs/cli 5.16.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.
- package/CHANGELOG.md +67 -0
- package/dist/check-diagnostics.d.ts +7 -0
- package/dist/check-diagnostics.d.ts.map +1 -1
- package/dist/check-diagnostics.js +3 -0
- package/dist/check-diagnostics.js.map +1 -1
- package/dist/check-scan-sql.d.ts +95 -0
- package/dist/check-scan-sql.d.ts.map +1 -0
- package/dist/check-scan-sql.js +1190 -0
- package/dist/check-scan-sql.js.map +1 -0
- package/dist/check-scan.d.ts +5 -93
- package/dist/check-scan.d.ts.map +1 -1
- package/dist/check-scan.js +20 -1207
- package/dist/check-scan.js.map +1 -1
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +9 -0
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts +2 -6
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +249 -80
- package/dist/cli.js.map +1 -1
- package/dist/command-catalog.d.ts +3 -0
- package/dist/command-catalog.d.ts.map +1 -1
- package/dist/command-catalog.js +18 -4
- package/dist/command-catalog.js.map +1 -1
- package/dist/frontend-guidance.js +1 -1
- package/dist/frontend-guidance.js.map +1 -1
- package/dist/internal/a11y-element.d.ts +33 -0
- package/dist/internal/a11y-element.d.ts.map +1 -0
- package/dist/internal/a11y-element.js +124 -0
- package/dist/internal/a11y-element.js.map +1 -0
- package/dist/internal/a11y-jsx.d.ts +12 -0
- package/dist/internal/a11y-jsx.d.ts.map +1 -0
- package/dist/internal/a11y-jsx.js +42 -0
- package/dist/internal/a11y-jsx.js.map +1 -0
- package/dist/internal/a11y-template.d.ts +11 -0
- package/dist/internal/a11y-template.d.ts.map +1 -0
- package/dist/internal/a11y-template.js +56 -0
- package/dist/internal/a11y-template.js.map +1 -0
- package/dist/internal/aria-data.d.ts +23 -0
- package/dist/internal/aria-data.d.ts.map +1 -0
- package/dist/internal/aria-data.js +220 -0
- package/dist/internal/aria-data.js.map +1 -0
- package/dist/internal/edit-distance.d.ts +3 -0
- package/dist/internal/edit-distance.d.ts.map +1 -0
- package/dist/internal/edit-distance.js +12 -0
- package/dist/internal/edit-distance.js.map +1 -0
- package/dist/internal/imported-as.d.ts +10 -0
- package/dist/internal/imported-as.d.ts.map +1 -0
- package/dist/internal/imported-as.js +23 -0
- package/dist/internal/imported-as.js.map +1 -0
- package/dist/internal/source-facts.d.ts +3 -0
- package/dist/internal/source-facts.d.ts.map +1 -1
- package/dist/internal/source-facts.js +2 -0
- package/dist/internal/source-facts.js.map +1 -1
- package/dist/internal/template-markup.d.ts +58 -0
- package/dist/internal/template-markup.d.ts.map +1 -0
- package/dist/internal/template-markup.js +221 -0
- package/dist/internal/template-markup.js.map +1 -0
- package/dist/internal/typescript-import.d.ts.map +1 -1
- package/dist/internal/typescript-import.js +11 -0
- package/dist/internal/typescript-import.js.map +1 -1
- package/dist/mcp-exec.d.ts.map +1 -1
- package/dist/mcp-exec.js +37 -23
- package/dist/mcp-exec.js.map +1 -1
- package/dist/mcp-http.js +1 -1
- package/dist/mcp-io.d.ts.map +1 -1
- package/dist/mcp-io.js +5 -3
- package/dist/mcp-io.js.map +1 -1
- package/dist/mcp-root.js +1 -1
- package/dist/mcp-root.js.map +1 -1
- package/dist/mcp-ws.d.ts.map +1 -1
- package/dist/mcp-ws.js +3 -2
- package/dist/mcp-ws.js.map +1 -1
- package/dist/migrate-layout-config.d.ts +63 -0
- package/dist/migrate-layout-config.d.ts.map +1 -0
- package/dist/migrate-layout-config.js +507 -0
- package/dist/migrate-layout-config.js.map +1 -0
- package/dist/migrate-layout-split.d.ts +46 -0
- package/dist/migrate-layout-split.d.ts.map +1 -0
- package/dist/migrate-layout-split.js +687 -0
- package/dist/migrate-layout-split.js.map +1 -0
- package/dist/migrate-layout.d.ts +4 -24
- package/dist/migrate-layout.d.ts.map +1 -1
- package/dist/migrate-layout.js +8 -1183
- package/dist/migrate-layout.js.map +1 -1
- package/dist/output-schemas.d.ts.map +1 -1
- package/dist/output-schemas.js +78 -10
- package/dist/output-schemas.js.map +1 -1
- package/dist/recipes/5.17.0.d.ts +10 -0
- package/dist/recipes/5.17.0.d.ts.map +1 -0
- package/dist/recipes/5.17.0.js +20 -0
- package/dist/recipes/5.17.0.js.map +1 -0
- package/dist/recipes/5.18.0.d.ts +9 -0
- package/dist/recipes/5.18.0.d.ts.map +1 -0
- package/dist/recipes/5.18.0.js +56 -0
- package/dist/recipes/5.18.0.js.map +1 -0
- package/dist/recipes/index.d.ts.map +1 -1
- package/dist/recipes/index.js +4 -0
- package/dist/recipes/index.js.map +1 -1
- package/dist/review.d.ts.map +1 -1
- package/dist/review.js +6 -0
- package/dist/review.js.map +1 -1
- package/dist/rules/a11y.d.ts +5 -0
- package/dist/rules/a11y.d.ts.map +1 -0
- package/dist/rules/a11y.js +78 -0
- package/dist/rules/a11y.js.map +1 -0
- package/dist/rules/codes.d.ts +6 -0
- package/dist/rules/codes.d.ts.map +1 -1
- package/dist/rules/codes.js +6 -0
- package/dist/rules/codes.js.map +1 -1
- package/dist/rules/comment-markers.js +1 -1
- package/dist/rules/comment-markers.js.map +1 -1
- package/dist/rules/explanations.d.ts.map +1 -1
- package/dist/rules/explanations.js +30 -0
- package/dist/rules/explanations.js.map +1 -1
- package/dist/rules/host-exposure.d.ts +23 -0
- package/dist/rules/host-exposure.d.ts.map +1 -0
- package/dist/rules/host-exposure.js +380 -0
- package/dist/rules/host-exposure.js.map +1 -0
- package/dist/rules/internal-links.d.ts.map +1 -1
- package/dist/rules/internal-links.js +16 -141
- package/dist/rules/internal-links.js.map +1 -1
- package/dist/rules/islands.d.ts +54 -0
- package/dist/rules/islands.d.ts.map +1 -1
- package/dist/rules/islands.js +577 -80
- package/dist/rules/islands.js.map +1 -1
- package/dist/rules/security.d.ts +1 -0
- package/dist/rules/security.d.ts.map +1 -1
- package/dist/rules/security.js +34 -7
- package/dist/rules/security.js.map +1 -1
- package/dist/runtime-differences.js +3 -3
- package/dist/runtime-differences.js.map +1 -1
- package/dist/scaffold.d.ts +1 -1
- package/dist/scaffold.d.ts.map +1 -1
- package/dist/scaffold.js +2 -2
- package/dist/scaffold.js.map +1 -1
- package/dist/source-rewrites.d.ts.map +1 -1
- package/dist/source-rewrites.js +2 -19
- package/dist/source-rewrites.js.map +1 -1
- package/docs/examples.json +4 -4
- package/docs/llms-full.txt +443 -46
- package/docs/types.json +490 -66
- package/package.json +12 -12
- package/src/check-diagnostics.ts +11 -0
- package/src/check-scan-sql.ts +1746 -0
- package/src/check-scan.ts +34 -1754
- package/src/check.ts +10 -1
- package/src/cli.ts +258 -98
- package/src/command-catalog.ts +21 -4
- package/src/frontend-guidance.ts +1 -1
- package/src/internal/a11y-element.ts +227 -0
- package/src/internal/a11y-jsx.ts +54 -0
- package/src/internal/a11y-template.ts +74 -0
- package/src/internal/aria-data.ts +242 -0
- package/src/internal/edit-distance.ts +16 -0
- package/src/internal/imported-as.ts +30 -0
- package/src/internal/source-facts.ts +4 -0
- package/src/internal/template-markup.ts +270 -0
- package/src/internal/typescript-import.ts +15 -0
- package/src/mcp-exec.ts +43 -22
- package/src/mcp-http.ts +1 -1
- package/src/mcp-io.ts +5 -3
- package/src/mcp-root.ts +1 -1
- package/src/mcp-ws.ts +3 -2
- package/src/migrate-layout-config.ts +615 -0
- package/src/migrate-layout-split.ts +870 -0
- package/src/migrate-layout.ts +37 -1468
- package/src/output-schemas.ts +85 -17
- package/src/recipes/5.17.0.ts +28 -0
- package/src/recipes/5.18.0.ts +63 -0
- package/src/recipes/index.ts +4 -0
- package/src/review.ts +6 -0
- package/src/rules/a11y.ts +119 -0
- package/src/rules/codes.ts +6 -0
- package/src/rules/comment-markers.ts +2 -2
- package/src/rules/explanations.ts +30 -0
- package/src/rules/host-exposure.ts +531 -0
- package/src/rules/internal-links.ts +21 -154
- package/src/rules/islands.ts +698 -86
- package/src/rules/security.ts +48 -7
- package/src/runtime-differences.ts +3 -3
- package/src/scaffold.ts +3 -3
- 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 (
|
|
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
|
-
|
|
867
|
-
|
|
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
|
-
|
|
880
|
-
for (
|
|
881
|
-
|
|
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 (
|
|
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 +=
|
|
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
|
|
1073
|
+
let start = 0
|
|
1074
|
+
let nl = this.stdoutBuffer.indexOf("\n", start)
|
|
1059
1075
|
while (nl !== -1) {
|
|
1060
|
-
const
|
|
1061
|
-
|
|
1062
|
-
this.stdoutBufferBytes
|
|
1063
|
-
|
|
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 (
|
|
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.
|
|
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
|
|
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
|
|
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 ||
|
|
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 (
|
|
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
|
|
157
|
+
if (data instanceof ArrayBuffer) return DECODER.decode(data)
|
|
157
158
|
if (ArrayBuffer.isView(data)) {
|
|
158
|
-
return
|
|
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)
|