@nifrajs/cli 5.3.0 → 5.5.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 (109) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/README.md +2 -1
  3. package/dist/check-scan.d.ts +6 -0
  4. package/dist/check-scan.d.ts.map +1 -1
  5. package/dist/check-scan.js +10 -10
  6. package/dist/check-scan.js.map +1 -1
  7. package/dist/check.d.ts.map +1 -1
  8. package/dist/check.js +1 -0
  9. package/dist/check.js.map +1 -1
  10. package/dist/cli.d.ts.map +1 -1
  11. package/dist/cli.js +6 -5
  12. package/dist/cli.js.map +1 -1
  13. package/dist/docs-search.d.ts +10 -1
  14. package/dist/docs-search.d.ts.map +1 -1
  15. package/dist/docs-search.js +86 -9
  16. package/dist/docs-search.js.map +1 -1
  17. package/dist/doctor.d.ts.map +1 -1
  18. package/dist/doctor.js +49 -4
  19. package/dist/doctor.js.map +1 -1
  20. package/dist/load.d.ts +4 -1
  21. package/dist/load.d.ts.map +1 -1
  22. package/dist/load.js +8 -0
  23. package/dist/load.js.map +1 -1
  24. package/dist/lock-links.d.ts.map +1 -1
  25. package/dist/lock-links.js +3 -1
  26. package/dist/lock-links.js.map +1 -1
  27. package/dist/mcp-http.js +1 -1
  28. package/dist/recipes/5.4.0.d.ts +10 -0
  29. package/dist/recipes/5.4.0.d.ts.map +1 -0
  30. package/dist/recipes/5.4.0.js +27 -0
  31. package/dist/recipes/5.4.0.js.map +1 -0
  32. package/dist/recipes/5.5.0.d.ts +9 -0
  33. package/dist/recipes/5.5.0.d.ts.map +1 -0
  34. package/dist/recipes/5.5.0.js +31 -0
  35. package/dist/recipes/5.5.0.js.map +1 -0
  36. package/dist/recipes/index.d.ts +7 -0
  37. package/dist/recipes/index.d.ts.map +1 -1
  38. package/dist/recipes/index.js +4 -0
  39. package/dist/recipes/index.js.map +1 -1
  40. package/dist/release-verification.d.ts +20 -0
  41. package/dist/release-verification.d.ts.map +1 -1
  42. package/dist/release-verification.js +62 -13
  43. package/dist/release-verification.js.map +1 -1
  44. package/dist/review.d.ts.map +1 -1
  45. package/dist/review.js +2 -0
  46. package/dist/review.js.map +1 -1
  47. package/dist/rules/codes.d.ts +2 -0
  48. package/dist/rules/codes.d.ts.map +1 -1
  49. package/dist/rules/codes.js +2 -0
  50. package/dist/rules/codes.js.map +1 -1
  51. package/dist/rules/explanations.d.ts.map +1 -1
  52. package/dist/rules/explanations.js +12 -2
  53. package/dist/rules/explanations.js.map +1 -1
  54. package/dist/rules/legacy.d.ts.map +1 -1
  55. package/dist/rules/legacy.js +63 -19
  56. package/dist/rules/legacy.js.map +1 -1
  57. package/dist/rules/security.d.ts +6 -0
  58. package/dist/rules/security.d.ts.map +1 -1
  59. package/dist/rules/security.js +152 -2
  60. package/dist/rules/security.js.map +1 -1
  61. package/dist/rules/zones.d.ts.map +1 -1
  62. package/dist/rules/zones.js +43 -1
  63. package/dist/rules/zones.js.map +1 -1
  64. package/dist/smoke.d.ts +17 -1
  65. package/dist/smoke.d.ts.map +1 -1
  66. package/dist/smoke.js +49 -0
  67. package/dist/smoke.js.map +1 -1
  68. package/dist/upgrade.d.ts +40 -12
  69. package/dist/upgrade.d.ts.map +1 -1
  70. package/dist/upgrade.js +182 -17
  71. package/dist/upgrade.js.map +1 -1
  72. package/dist/verification-plan.d.ts +4 -0
  73. package/dist/verification-plan.d.ts.map +1 -1
  74. package/dist/verification-plan.js +48 -0
  75. package/dist/verification-plan.js.map +1 -1
  76. package/dist/version-drift.d.ts +2 -1
  77. package/dist/version-drift.d.ts.map +1 -1
  78. package/dist/version-drift.js +11 -26
  79. package/dist/version-drift.js.map +1 -1
  80. package/dist/web-app-options.d.ts +1 -1
  81. package/dist/web-app-options.d.ts.map +1 -1
  82. package/dist/web-app-options.js.map +1 -1
  83. package/docs/examples.json +14 -2
  84. package/docs/llms-full.txt +759 -199
  85. package/docs/types.json +258 -44
  86. package/package.json +11 -11
  87. package/src/check-scan.ts +10 -12
  88. package/src/check.ts +1 -0
  89. package/src/cli.ts +6 -5
  90. package/src/docs-search.ts +90 -10
  91. package/src/doctor.ts +60 -4
  92. package/src/load.ts +13 -0
  93. package/src/lock-links.ts +3 -1
  94. package/src/mcp-http.ts +1 -1
  95. package/src/recipes/5.4.0.ts +28 -0
  96. package/src/recipes/5.5.0.ts +32 -0
  97. package/src/recipes/index.ts +11 -0
  98. package/src/release-verification.ts +88 -12
  99. package/src/review.ts +2 -0
  100. package/src/rules/codes.ts +2 -0
  101. package/src/rules/explanations.ts +12 -2
  102. package/src/rules/legacy.ts +75 -20
  103. package/src/rules/security.ts +171 -2
  104. package/src/rules/zones.ts +44 -1
  105. package/src/smoke.ts +70 -0
  106. package/src/upgrade.ts +199 -21
  107. package/src/verification-plan.ts +51 -0
  108. package/src/version-drift.ts +18 -26
  109. package/src/web-app-options.ts +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nifrajs/cli",
3
- "version": "5.3.0",
3
+ "version": "5.5.0",
4
4
  "description": "The nifra CLI - zero-config dev/build/start for a nifra app (`nifra dev`, `nifra build`, `nifra start`).",
5
5
  "keywords": [
6
6
  "bun",
@@ -70,16 +70,16 @@
70
70
  "access": "public"
71
71
  },
72
72
  "dependencies": {
73
- "@nifrajs/client": "5.3.0",
74
- "@nifrajs/core": "5.3.0",
75
- "@nifrajs/agent-review": "5.3.0",
76
- "@nifrajs/i18n": "5.3.0",
77
- "@nifrajs/mcp": "5.3.0",
78
- "@nifrajs/mcp-db": "5.3.0",
79
- "@nifrajs/runner": "5.3.0",
80
- "@nifrajs/schema": "5.3.0",
81
- "@nifrajs/testing": "5.3.0",
82
- "@nifrajs/web": "5.3.0"
73
+ "@nifrajs/client": "5.5.0",
74
+ "@nifrajs/core": "5.5.0",
75
+ "@nifrajs/agent-review": "5.5.0",
76
+ "@nifrajs/i18n": "5.5.0",
77
+ "@nifrajs/mcp": "5.5.0",
78
+ "@nifrajs/mcp-db": "5.5.0",
79
+ "@nifrajs/runner": "5.5.0",
80
+ "@nifrajs/schema": "5.5.0",
81
+ "@nifrajs/testing": "5.5.0",
82
+ "@nifrajs/web": "5.5.0"
83
83
  },
84
84
  "repository": {
85
85
  "type": "git",
package/src/check-scan.ts CHANGED
@@ -148,7 +148,7 @@ const DB_MODULE = /^(?:\.\.?\/)+db(?:\.[cm]?[jt]sx?)?$/
148
148
  * module, a bare builtin with no browser counterpart, or a package the browser build refuses
149
149
  * (`SERVER_PACKAGES` and the driver entries of `@nifrajs/web/zones`).
150
150
  */
151
- function isServerOnlySink(specifier: string): boolean {
151
+ export function isServerOnlySink(specifier: string): boolean {
152
152
  return (
153
153
  /^(?:node:|bun:)/.test(specifier) ||
154
154
  SERVER_BUILTINS.has(specifier) ||
@@ -1013,7 +1013,8 @@ function scanMethodRoutes(
1013
1013
  ALL_ROUTES.lastIndex = 0
1014
1014
  for (let m = ALL_ROUTES.exec(code); m !== null; m = ALL_ROUTES.exec(code)) {
1015
1015
  const double = m[1] !== undefined
1016
- collect(m.index, "all", 0, double ? m[1] : m[2], double ? '"' : "'", [...HTTP_VERBS])
1016
+ // all() also registers QUERY, which has no builder of its own and so is not in HTTP_VERBS.
1017
+ collect(m.index, "all", 0, double ? m[1] : m[2], double ? '"' : "'", [...HTTP_VERBS, "QUERY"])
1017
1018
  }
1018
1019
  METHOD_ROUTES.lastIndex = 0
1019
1020
  for (let m = METHOD_ROUTES.exec(code); m !== null; m = METHOD_ROUTES.exec(code)) {
@@ -3462,23 +3463,19 @@ const RAW_RESPONSE_EXPECTATION = ["NF-C007", "raw-response"]
3462
3463
  async function gitIgnored(cwd: string, rels: readonly string[]): Promise<Set<string>> {
3463
3464
  if (rels.length === 0) return new Set()
3464
3465
  try {
3465
- const proc = Bun.spawn(["git", "check-ignore", "--stdin"], {
3466
+ const proc = Bun.spawn(["git", "check-ignore", "--stdin", "-z"], {
3466
3467
  cwd,
3467
3468
  stdin: "pipe",
3468
3469
  stdout: "pipe",
3469
3470
  stderr: "ignore",
3470
3471
  })
3471
- proc.stdin.write(`${rels.join("\n")}\n`)
3472
+ proc.stdin.write(`${rels.join("\0")}\0`)
3472
3473
  await proc.stdin.end()
3473
- // git echoes back each ignored path exactly as fed on stdin (one per line); exit 1 = none matched.
3474
+ // -z keeps both directions literal: Git otherwise C-quotes Unicode/escapes on output and
3475
+ // interprets quoted input. Only matching paths are emitted; exit 1 means none matched.
3474
3476
  const out = await new Response(proc.stdout).text()
3475
3477
  await proc.exited
3476
- return new Set(
3477
- out
3478
- .split("\n")
3479
- .map((s) => s.trim())
3480
- .filter(Boolean),
3481
- )
3478
+ return new Set(out.split("\0").filter((path) => path !== ""))
3482
3479
  } catch {
3483
3480
  return new Set()
3484
3481
  }
@@ -3507,7 +3504,8 @@ export async function walkSource(
3507
3504
  // one batch before the (expensive) reads. So a gitignored generated/build tree is never read or scanned.
3508
3505
  const rels: string[] = []
3509
3506
  for await (const rawRel of new Glob(pattern).scan({ cwd, dot: false })) {
3510
- const rel = normalizeProjectPath(rawRel)
3507
+ // A backslash is a filename character on POSIX; only Windows separators need normalizing.
3508
+ const rel = sep === "\\" ? normalizeProjectPath(rawRel) : rawRel
3511
3509
  // A `.js` file outside a zone is tooling (a bundler config, a script, a vendored asset), not app code.
3512
3510
  if (PLAIN_SCRIPT_FILE.test(rel) && !ZONED_PATH.test(rel)) continue
3513
3511
  if (!skip.test(rel) && (opts.ignore === undefined || !opts.ignore(rel))) rels.push(rel)
package/src/check.ts CHANGED
@@ -623,6 +623,7 @@ const REPORT_SECTIONS = [
623
623
  ["response-route", "route returns a raw Response (typed client → data: never)"],
624
624
  ["undeclared-dependency", "undeclared dependency in package.json"],
625
625
  ["duplicate-install", "duplicate identity-sensitive dependency install"],
626
+ ["version-skew", "identity-sensitive dependency at more than one version"],
626
627
  ["stale-workspace-dist", "workspace-linked dist older than its source"],
627
628
  ["pipeline", "bundler pipeline (Vite/Bun) config"],
628
629
  ["server-manifest-drift", "server-manifest.ts drifted from routes/"],
package/src/cli.ts CHANGED
@@ -19,6 +19,7 @@ import {
19
19
  DEFAULT_DEV_PORT,
20
20
  type RenderAdapter,
21
21
  } from "@nifrajs/web"
22
+ import { formatBuildLog } from "@nifrajs/web/diagnostic"
22
23
  import { discoverRoutes } from "@nifrajs/web/fs"
23
24
  import { formatShadowedPages, shadowedPages } from "@nifrajs/web/route-manifest"
24
25
  import type { BunPlugin } from "bun"
@@ -334,7 +335,7 @@ set in the process environment is never overwritten by a file.
334
335
  ${renderCommandCatalogHelp()}`
335
336
 
336
337
  // Kept in lockstep with packages/cli/package.json by check:publish's version-consistency gate.
337
- const CLI_VERSION = "5.3.0"
338
+ const CLI_VERSION = "5.5.0"
338
339
 
339
340
  // A render adapter + nifra server are opaque to the CLI (it just forwards them); cast at the seam.
340
341
  const asAdapter = (v: unknown): RenderAdapter => v as RenderAdapter
@@ -373,10 +374,10 @@ export function formatCliError(err: unknown): string {
373
374
  if (aggregate !== undefined && aggregate.errors.length > 0) {
374
375
  const outer = err instanceof Error ? err.message : ""
375
376
  const head = outer !== "" && outer !== "Bundle failed" ? outer : "build failed"
376
- // `String(e)` (not `e.message`) so a Bun BuildMessage/ResolveMessage renders with its file + line,
377
- // not just the bare text. Multi-line entries are indented to stay under the head. Deduplicated
378
- // because Bun can repeat one cause across `.errors`.
379
- const details = [...new Set(aggregate.errors.map((e) => String(e).trim()))].map(
377
+ // `formatBuildLog`, not `String(e)`: a Bun BuildMessage/ResolveMessage keeps its file and line in
378
+ // `position`, which `String` drops. Multi-line entries are indented to stay under the head.
379
+ // Deduplicated because Bun can repeat one cause across `.errors`.
380
+ const details = [...new Set(aggregate.errors.map((e) => formatBuildLog(e).trim()))].map(
380
381
  (line) => ` - ${line.replace(/\n/g, "\n ")}`,
381
382
  )
382
383
  return [head, ...details].join("\n")
@@ -3,7 +3,9 @@
3
3
  * `llms-full.txt` (written into this package by `bun run gen:llms`, so it can't drift from the
4
4
  * source it's generated from). Instead of dumping the whole ~150 KB into an agent's context, the
5
5
  * tool keyword-scores the document's `##` sections and returns only the top matches - or, with no
6
- * query, just the section index (the cheap discovery call).
6
+ * query, just the section index (the cheap discovery call). A matched page too long to return whole
7
+ * is narrowed to its `###` subsections that match, after the page's lead and before a list of the
8
+ * rest, so the answer is the part asked about rather than the page's first screen.
7
9
  *
8
10
  * Deliberately NOT a vector search: the corpus is one curated document with descriptive headings;
9
11
  * weighted keyword scoring over sections is deterministic, dependency-free, and good enough that
@@ -102,6 +104,92 @@ export function searchSections(
102
104
  /** Cap a section body for the tool result - whole sections can be pages long; the agent can ask
103
105
  * again with a narrower query if the trim cuts what it needed. */
104
106
  const MAX_SECTION_CHARS = 2800
107
+ /** The page lead kept above its matched subsections: enough to say what the page is. */
108
+ const MAX_LEAD_CHARS = 600
109
+ /** The best subsection is the answer, so it may run past the section cap; a whole worked example fits. */
110
+ const MAX_SUBSECTION_CHARS = 6000
111
+
112
+ /** A code fence line: a run of three or more backticks or tildes, indented at most three spaces. */
113
+ const FENCE = /^ {0,3}(`{3,}|~{3,})(.*)$/
114
+
115
+ /** A page body's lead (before its first `###`) and its `###` subsections. Fenced code is skipped,
116
+ * so a `###` line inside a snippet is not a heading. A fence closes only on a run of its own marker
117
+ * at least as long, as in CommonMark, so a snippet that shows a fence does not end the one around it. */
118
+ export function splitSubsections(body: string): { lead: string; parts: DocSection[] } {
119
+ const parts: DocSection[] = []
120
+ let lead = ""
121
+ let heading: string | undefined
122
+ let buf: string[] = []
123
+ let fence: string | undefined
124
+ const flush = (): void => {
125
+ const text = buf.join("\n").trim()
126
+ if (heading === undefined) lead = text
127
+ else parts.push({ heading, body: text })
128
+ buf = []
129
+ }
130
+ for (const line of body.split("\n")) {
131
+ const [, run, rest = ""] = FENCE.exec(line) ?? []
132
+ if (run !== undefined) {
133
+ if (fence === undefined) {
134
+ // A backtick fence's info string cannot hold a backtick: such a line is inline code.
135
+ if (!(run.startsWith("`") && rest.includes("`"))) fence = run
136
+ } else if (run[0] === fence[0] && run.length >= fence.length && rest.trim() === "") {
137
+ fence = undefined
138
+ }
139
+ }
140
+ if (fence === undefined && line.startsWith("### ")) {
141
+ flush()
142
+ heading = line.slice(4).trim()
143
+ } else {
144
+ buf.push(line)
145
+ }
146
+ }
147
+ flush()
148
+ return { lead, parts }
149
+ }
150
+
151
+ function capped(text: string, max: number, note: string): string {
152
+ return text.length > max ? `${text.slice(0, max)}\n…(${note})` : text
153
+ }
154
+
155
+ /** One matched page: whole when it fits, otherwise its lead, the subsections the query matches
156
+ * (best first, at least one, within the size cap) and the headings of the others. */
157
+ function renderMatch(match: DocSection, query: string): string {
158
+ if (match.body.length <= MAX_SECTION_CHARS) return `## ${match.heading}\n\n${match.body}`
159
+ const { lead, parts } = splitSubsections(match.body)
160
+ const ranked = parts.length === 0 ? [] : searchSections(parts, query, parts.length)
161
+ if (ranked.length === 0) {
162
+ const others =
163
+ parts.length === 0
164
+ ? ""
165
+ : `\n\nSubsections: ${parts.map((part) => part.heading).join(" | ")} - query one by name for its text.`
166
+ return `## ${match.heading}\n\n${capped(match.body, MAX_SECTION_CHARS, "trimmed - narrow the query for the rest")}${others}`
167
+ }
168
+ const shown: ScoredSection[] = []
169
+ let used = 0
170
+ for (const part of ranked) {
171
+ if (
172
+ shown.length > 0 &&
173
+ (used + part.body.length > MAX_SECTION_CHARS || part.score * 2 < ranked[0]!.score)
174
+ ) {
175
+ break
176
+ }
177
+ shown.push(part)
178
+ used += part.body.length
179
+ }
180
+ const shownHeadings = new Set(shown.map((part) => part.heading))
181
+ const others = parts
182
+ .filter((part) => !shownHeadings.has(part.heading))
183
+ .map((part) => part.heading)
184
+ const body = shown
185
+ .map(
186
+ (part, index) =>
187
+ `### ${part.heading}\n\n${capped(part.body, index === 0 ? MAX_SUBSECTION_CHARS : MAX_SECTION_CHARS, "trimmed")}`,
188
+ )
189
+ .join("\n\n")
190
+ const rest = others.length === 0 ? "" : `\n\nAlso on this page: ${others.join(" | ")}`
191
+ return `## ${match.heading}\n\n${capped(lead, MAX_LEAD_CHARS, "lead trimmed")}\n\n${body}${rest}`
192
+ }
105
193
 
106
194
  /** Render the tool result: matched sections, or the index when no query was given. */
107
195
  export function renderDocsResult(
@@ -118,15 +206,7 @@ export function renderDocsResult(
118
206
  if (matches.length === 0) {
119
207
  return `No docs sections matched ${JSON.stringify(query)}. Call without a query for the section index.`
120
208
  }
121
- return matches
122
- .map((m) => {
123
- const body =
124
- m.body.length > MAX_SECTION_CHARS
125
- ? `${m.body.slice(0, MAX_SECTION_CHARS)}\n…(trimmed - narrow the query for the rest)`
126
- : m.body
127
- return `## ${m.heading}\n\n${body}`
128
- })
129
- .join("\n\n---\n\n")
209
+ return matches.map((match) => renderMatch(match, query)).join("\n\n---\n\n")
130
210
  }
131
211
 
132
212
  /** Load the bundled corpus. Resolves relative to this module so it works from `src/` (repo dev)
package/src/doctor.ts CHANGED
@@ -17,7 +17,7 @@
17
17
  * undeclared import there fails a clean `bun install --frozen-lockfile` build just the same.
18
18
  */
19
19
  import type { Dirent } from "node:fs"
20
- import { readdir, stat } from "node:fs/promises"
20
+ import { readdir, realpath, stat } from "node:fs/promises"
21
21
  import { builtinModules } from "node:module"
22
22
  import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path"
23
23
  import {
@@ -48,6 +48,7 @@ import {
48
48
  import { detectToolingDrift, syncMcpCommand, type ToolingDrift } from "./mcp-root.ts"
49
49
  import { collectPipelineReport, type PipelineReport } from "./pipeline-report.ts"
50
50
  import { type ResolvedTarget, resolveTarget } from "./port.ts"
51
+ import { isFixedGroup, resolvePackageFrom } from "./upgrade.ts"
51
52
  import { collectVersionDrift, type VersionDrift, versionDriftMessage } from "./version-drift.ts"
52
53
  import { buildScriptName } from "./workspace-link.ts"
53
54
 
@@ -629,6 +630,8 @@ interface ReadinessSource {
629
630
  readonly file: string
630
631
  readonly code: string
631
632
  readonly source: string
633
+ /** The linked package the file belongs to, when it is not the app's own. */
634
+ readonly via?: string
632
635
  }
633
636
 
634
637
  function sourceLineAt(source: string, index: number): number {
@@ -645,21 +648,74 @@ function readinessEvidence(
645
648
  for (const file of files) {
646
649
  const content = source === "source" ? file.source : file.code
647
650
  const match = pattern.exec(content)
648
- if (match !== null) return `${file.file}:${sourceLineAt(content, match.index)}`
651
+ if (match !== null)
652
+ return `${file.file}:${sourceLineAt(content, match.index)}${file.via === undefined ? "" : ` via ${file.via}`}`
649
653
  }
650
654
  return undefined
651
655
  }
652
656
 
657
+ function readinessSource(file: string, source: string, via?: string): ReadinessSource {
658
+ const code = codePositionMask(source)
659
+ return via === undefined ? { file, source, code } : { file, source, code, via }
660
+ }
661
+
662
+ /**
663
+ * The source of every package the app imports from outside its own tree that is not a registry
664
+ * install (a `file:` or `link:` dependency, a workspace sibling), and of those it imports in turn: a
665
+ * server factory such a package builds is this app's server. nifra's own packages are skipped - they
666
+ * define these settings, they do not apply them.
667
+ */
668
+ async function linkedReadinessSources(
669
+ cwd: string,
670
+ files: readonly ReadinessSource[],
671
+ ): Promise<ReadinessSource[]> {
672
+ let root: string
673
+ try {
674
+ root = await realpath(cwd)
675
+ } catch {
676
+ root = resolve(cwd)
677
+ }
678
+ const visited = new Set<string>([root])
679
+ const linked: ReadinessSource[] = []
680
+ const follow = async (from: string, sources: readonly ReadinessSource[]): Promise<void> => {
681
+ const imported = new Set(
682
+ sources.flatMap((file) =>
683
+ scanUndeclaredImports(file.file, file.source, new Set(), () => false).map(
684
+ (finding) => finding.snippet,
685
+ ),
686
+ ),
687
+ )
688
+ for (const name of [...imported].sort(codeUnitOrder)) {
689
+ if (isFixedGroup(name)) continue
690
+ const path = resolvePackageFrom(from, name)
691
+ if (path === undefined || visited.has(path) || path.split(sep).includes("node_modules"))
692
+ continue
693
+ if (path === root || path.startsWith(root + sep)) continue
694
+ visited.add(path)
695
+ const own: ReadinessSource[] = []
696
+ await walkSource(path, (rel, source) => {
697
+ own.push(readinessSource(displayPath(root, join(path, rel)), source, name))
698
+ })
699
+ linked.push(...own)
700
+ await follow(path, own)
701
+ }
702
+ }
703
+ await follow(root, files)
704
+ return linked
705
+ }
706
+
653
707
  /** Read only source shapes used to report production readiness. Values and secrets are never loaded. */
654
708
  async function collectDoctorReadiness(
655
709
  cwd: string,
656
710
  opts: { readonly target?: string; readonly strict?: boolean },
657
711
  ): Promise<DoctorReadiness> {
658
712
  const resolved = await resolveTarget(cwd, opts.target)
659
- const files: ReadinessSource[] = []
713
+ const own: ReadinessSource[] = []
660
714
  await walkSource(cwd, (file, source) => {
661
- files.push({ file, source, code: codePositionMask(source) })
715
+ own.push(readinessSource(file, source))
662
716
  })
717
+ // The app's own files first, so a setting it makes itself is the evidence shown.
718
+ const files = [...own, ...(await linkedReadinessSources(cwd, own))]
663
719
  const edgeTarget = /^(?:cloudflare|vercel|workers|edge|static)$/.test(resolved?.target ?? "")
664
720
  const configured = (
665
721
  id: DoctorReadinessItem["id"],
package/src/load.ts CHANGED
@@ -116,6 +116,9 @@ export interface NifraFramework {
116
116
  * takes its `<html lang dir>`, `Content-Language` and adapter locale from it. See `createWebApp`'s
117
117
  * `i18n`. */
118
118
  readonly i18n?: CreateWebAppOptions["i18n"]
119
+ /** Which pages and files each host serves, from `createHostPolicy()`: checked before the app's
120
+ * static files, mounts and pages. See `createWebApp`'s `hostPolicy`. */
121
+ readonly hostPolicy?: CreateWebAppOptions["hostPolicy"]
119
122
  }
120
123
 
121
124
  /** The {@link NifraFramework} fields forwarded to `createWebApp` and imported by the generated server
@@ -128,6 +131,7 @@ export const FRAMEWORK_WEB_OPTIONS = [
128
131
  "nonce",
129
132
  "serverComponents",
130
133
  "i18n",
134
+ "hostPolicy",
131
135
  ] as const
132
136
  export type FrameworkWebOption = (typeof FRAMEWORK_WEB_OPTIONS)[number]
133
137
 
@@ -174,6 +178,15 @@ function assertFrameworkWebOptions(fw: Partial<NifraFramework>, configFile: stri
174
178
  ) {
175
179
  wrong("i18n", "the router defineI18nRouting() from @nifrajs/i18n/routing returns")
176
180
  }
181
+ if (
182
+ fw.hostPolicy !== undefined &&
183
+ (typeof fw.hostPolicy !== "object" ||
184
+ fw.hostPolicy === null ||
185
+ typeof fw.hostPolicy.allows !== "function" ||
186
+ typeof fw.hostPolicy.check !== "function")
187
+ ) {
188
+ wrong("hostPolicy", "the policy createHostPolicy() from @nifrajs/web returns")
189
+ }
177
190
  if (fw.publicEnvPrefix !== undefined && typeof fw.publicEnvPrefix !== "string") {
178
191
  wrong("publicEnvPrefix", 'a string such as "PUBLIC_", or "" to expose no environment variable')
179
192
  }
package/src/lock-links.ts CHANGED
@@ -11,9 +11,11 @@ import { parseJsonc } from "./internal/project-specifiers.ts"
11
11
 
12
12
  export const BUN_LOCK = "bun.lock"
13
13
 
14
- /** The fields Bun installs from a linked package's manifest. */
14
+ /** The fields Bun installs from a linked package's manifest: unlike a registry package's, a `file:`
15
+ * package's devDependencies are recorded and installed too (checked on Bun 1.4.3). */
15
16
  const INSTALLED_FIELDS: readonly string[] = [
16
17
  "dependencies",
18
+ "devDependencies",
17
19
  "optionalDependencies",
18
20
  "peerDependencies",
19
21
  ]
package/src/mcp-http.ts CHANGED
@@ -29,7 +29,7 @@ export { docsTools } from "./mcp-docs-tools.ts"
29
29
  export type { TypeEntry } from "./types-search.ts"
30
30
 
31
31
  // Kept in lockstep with packages/cli/package.json by check:publish's version-consistency gate.
32
- const VERSION = "5.3.0"
32
+ const VERSION = "5.5.0"
33
33
  const SERVER_INFO = { name: "nifra-docs", version: VERSION }
34
34
  // Derive the GET/health tool list from the tools actually served, so the line can never drift from them.
35
35
  const docsHealth = (tools: McpTool[]): string =>
@@ -0,0 +1,28 @@
1
+ import type { UpgradeRecipe } from "./index.ts"
2
+
3
+ /**
4
+ * Upgrade recipe for Nifra 5.4.
5
+ *
6
+ * No import or dependency moves. A `node` build needs the adapter of the same release, and static
7
+ * files answer validators, ranges and types the same way on every runtime; each note says what an
8
+ * app or a client sees differently.
9
+ */
10
+ export const recipe: UpgradeRecipe = {
11
+ version: "5.4.0",
12
+ pins: [
13
+ { match: "@nifrajs/", to: "5.4.0" },
14
+ { match: "create-nifra", to: "5.4.0" },
15
+ { match: "nifra", to: "5.4.0" },
16
+ ],
17
+ importMoves: [],
18
+ // `@nifrajs/core` gained `static-file`, which only these load; `nifra dev` serves files with web's reader.
19
+ affects: ["@nifrajs/cli", "@nifrajs/node", "@nifrajs/web"],
20
+ notes: [
21
+ "The server entry a `node` build generates passes the app itself to `@nifrajs/node`'s `serve` and serves files with the adapter's own reader, so it needs the `@nifrajs/node` of the same release. With an older adapter installed the build stops before bundling, names both versions and leaves the last deploy dir in place, where a 5.3 adapter used to build and then throw when the server started. Upgrade `@nifrajs/node` with the rest.",
22
+ "Static files carry a strong `ETag` from their content (128 bits of SHA-256) on the Bun entry and `nifra dev` (`servePublicDir`), `@nifrajs/node`'s `static` reader and the generated Deno entry, the same for the same bytes on every instance. The Node reader's `\"<mtime>-<size>\"` tag is gone, so clients and caches revalidate each file once after the upgrade. `Last-Modified` is sent only while a file's mtime is its own last change, so a file whose mtime a copy or build set (every file in a container image) is sent without one and `If-Modified-Since` cannot validate it. An `If-Range` date no longer keeps a range for a tagged file; a client resumes by the tag.",
23
+ "The generated Deno entry answers static files with `etag` and `last-modified`, a `304` with no body for a current copy (HEAD included), and honors `Range` only when `If-Range` is absent or names the file's current validator, as the Bun and Node entries do. On Bun and Deno `If-None-Match` is evaluated before `If-Modified-Since`, so a stale entity tag no longer gets a `304` from the date beside it.",
24
+ "`@nifrajs/node`'s `serve({ static })` types files from the same table as `servePublicDir`, so `.pdf`, `.mp4`, `.xml`, `.csv` and other common types are no longer sent as `application/octet-stream`. It serves `/.well-known` by default, refuses a visible name that links to a dotfile, and answers a link that leaves the directory with `404` where it answered `403`. `static` also takes an array of mounts, a `files` list a mount is limited to, and `cacheControl`.",
25
+ "`@nifrajs/node`'s `static` reader parses `Range` with `@nifrajs/core/range`, like the other runtimes: overlapping or adjacent ranges are served as the one range they cover, a satisfiable range listed with unsatisfiable ones is served, an inverted range (`bytes=9-0`) answers `416` where it was ignored, a zero-length suffix (`bytes=-0`) sends the whole file where it answered `416`, and a `Range` longer than 16 KiB is ignored.",
26
+ "On Bun, `servePublicDir` (the Bun entry and `nifra dev`) sends `content-length` for files up to 1 MiB, whole or ranged, where Bun used to send them chunked with no length. Files above 1 MiB are still sent chunked.",
27
+ ],
28
+ }
@@ -0,0 +1,32 @@
1
+ import type { UpgradeRecipe } from "./index.ts"
2
+
3
+ /**
4
+ * Upgrade recipe for Nifra 5.5.
5
+ *
6
+ * No import moves. An app on the server-component pipeline moves its React stack to 19.3.1 together;
7
+ * each note says what an app or a client sees differently.
8
+ */
9
+ export const recipe: UpgradeRecipe = {
10
+ version: "5.5.0",
11
+ pins: [
12
+ { match: "@nifrajs/", to: "5.5.0" },
13
+ { match: "create-nifra", to: "5.5.0" },
14
+ { match: "nifra", to: "5.5.0" },
15
+ { match: "react-server-dom-webpack", to: "19.3.1" },
16
+ ],
17
+ importMoves: [],
18
+ notes: [
19
+ "The server-component pipeline is certified on React, React DOM and `react-server-dom-webpack` 19.3.1 with Vite 8.2.1. `react-server-dom-webpack` is pinned here; set `react` and `react-dom` to exactly 19.3.1 as well. Until all three match, the plugin's guard stops the build and `nifra check` names each installed version. On Bun, server components need Bun 1.3.14 or later: earlier 1.3 releases cannot parse React 19.3.1's server renderer.",
20
+ "Workbench loads a project's `.nifra/extensions/**` only when started with `--extensions`, as `nifra-agent` does. A Pi-backed session without the flag runs no project extension code; pass it only for a repository you trust.",
21
+ "An idempotent route that authenticates first runs its `authenticate()` stages before the idempotency key is checked or the body is read, so a bad credential gets the route's `401` without buffering the body. The dedupe step runs under `requestTimeoutMs` and answers `503` when the resolver or store stalls, and a different payload under a used key answers `409 idempotency_key_reused` instead of replaying the first response.",
22
+ "A response `transportCodecs()` negotiates carries `Vary: Accept`, and `cache()` stores it only when its `vary` includes `accept`. A request the codecs decode keeps the body and `Content-Type` it was sent with, so a route without a body schema reads the payload itself from `c.req` instead of a `{}` stand-in. `compression()` adds `Vary: Accept-Encoding` to an identity response it would have gzipped for another client.",
23
+ "`stripImageMetadata()` refuses a source larger than `maxPixels` (default 40 MP) before decoding it, throwing `ImagePixelLimitError`; answer it with `413`. `signDownloadUrl()` throws a `RangeError` for an `expiresInSeconds` that is not a whole number of seconds of at least 1, where it used to sign a link that never verified.",
24
+ "A store-backed session loaded before a logout or rotation is never written back by that request's `commit()`: a loaded session commits only while its record exists and no revocation marker names it. A custom `SessionStore` may implement the new optional `replace(id, record)`, an atomic write only while the record exists that also sets its expiry, and renewals then go through it; a store without it must keep each revocation marker until its `expiresAt`. `regenerate()` now issues the original ID, `~` and a new random part, and logout with any generation's cookie revokes them all: a custom store keeps every `<id>.revoked` and `<id>.rotated` marker until its `expiresAt`, and may implement the optional atomic `rotate(previousId, nextId, record, marker)`.",
25
+ "A static file over 256 KiB streams without an automatic `ETag`. Once its last change is more than 2 seconds old it revalidates by `Last-Modified`, and a `Range` request guarded by `If-Range` gets the whole file. Smaller files keep their content `ETag`.",
26
+ "`AgentAppClient.send()` and `HttpAgentTransport.stream()` reject with `AgentTurnError` when the host ends a turn with its `error` frame, where the turn used to complete as a success. A throwing `authorize()` callback rejects with `authorize() failed` and none of its own message.",
27
+ "`createMemoryAgentEvidenceLog` keeps at most `maxEvidencePerTurn` items per turn (default 1024) across every resume of it, and a reconnect whose `Last-Event-ID` is older than what it holds answers `409 replay_unavailable`. `IsolatedExtensionWorker.start()` rejects when the worker exits before it is ready or is not ready within `startTimeoutMs` (default 30 s).",
28
+ "The generated service worker fails its install when a precache response is an error, a redirect, or `Cache-Control: private` or `no-store`, and a runtime cache miss skips a `private` response. A client navigation to a prerendered path with a query string fetches its data from the server instead of the static `_data.json`.",
29
+ "The compact edge server answers a body validator that throws and a handler value that cannot be serialized (a `BigInt`, a circular object) with the flat `500 internal_error`, as the full server does, where `fetch()` used to reject. `run_query` in `@nifrajs/mcp-db` answers a SQLite INTEGER past 2^53 as its exact decimal string.",
30
+ "`nifra check` reports an identity-sensitive package installed at more than one version as NF-C046, an error, where it reported NF-C009. A `nifra.check.json` override of NF-C009 no longer applies to it: install one version in every install root that carries a copy (`nifra upgrade` in a linked repository too), since a `singleCopy` declaration never covers a version skew. NF-S002 also reads names ending in `serviceKey`, `privateKey`, `signingKey`, `masterKey` and `encryptionKey` as secrets, and no longer reports a comparison of two `const`s loaded from configuration.",
31
+ ],
32
+ }
@@ -15,6 +15,8 @@ import { recipe as v5_0_0 } from "./5.0.0.ts"
15
15
  import { recipe as v5_1_0 } from "./5.1.0.ts"
16
16
  import { recipe as v5_2_0 } from "./5.2.0.ts"
17
17
  import { recipe as v5_3_0 } from "./5.3.0.ts"
18
+ import { recipe as v5_4_0 } from "./5.4.0.ts"
19
+ import { recipe as v5_5_0 } from "./5.5.0.ts"
18
20
 
19
21
  /** A pin rule: every dependency whose name starts with `match` is set to version `to`. */
20
22
  export interface PinRule {
@@ -52,6 +54,13 @@ export interface UpgradeRecipe {
52
54
  readonly retiredMarkers?: readonly RetiredMarker[]
53
55
  /** Human notes printed after the plan - e.g. structural changes the runner deliberately can't do. */
54
56
  readonly notes?: readonly string[]
57
+ /**
58
+ * The fixed-group packages whose behaviour the notes describe changing (a tool such as
59
+ * `@nifrajs/cli` is listed itself when what it does changes). `nifra upgrade` marks the release as
60
+ * no announced behaviour change for a project that loads none of them. Omitted, every project is
61
+ * treated as affected.
62
+ */
63
+ readonly affects?: readonly string[]
55
64
  }
56
65
 
57
66
  const RECIPES: Record<string, UpgradeRecipe> = {
@@ -63,6 +72,8 @@ const RECIPES: Record<string, UpgradeRecipe> = {
63
72
  [v5_1_0.version]: v5_1_0,
64
73
  [v5_2_0.version]: v5_2_0,
65
74
  [v5_3_0.version]: v5_3_0,
75
+ [v5_4_0.version]: v5_4_0,
76
+ [v5_5_0.version]: v5_5_0,
66
77
  }
67
78
 
68
79
  export function getRecipe(version: string): UpgradeRecipe | undefined {