@nifrajs/cli 5.7.0 → 5.9.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 +150 -0
- package/dist/agent-files.d.ts +0 -22
- package/dist/agent-files.d.ts.map +1 -1
- package/dist/agent-files.js +3 -1
- package/dist/agent-files.js.map +1 -1
- package/dist/assure-hydration.d.ts.map +1 -1
- package/dist/assure-hydration.js +2 -10
- package/dist/assure-hydration.js.map +1 -1
- package/dist/assure.d.ts.map +1 -1
- package/dist/assure.js +3 -3
- package/dist/assure.js.map +1 -1
- package/dist/check-scan.d.ts +2 -0
- package/dist/check-scan.d.ts.map +1 -1
- package/dist/check-scan.js +54 -86
- package/dist/check-scan.js.map +1 -1
- package/dist/check.d.ts +3 -0
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +20 -23
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts +8 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +42 -13
- package/dist/cli.js.map +1 -1
- package/dist/command-catalog.d.ts.map +1 -1
- package/dist/command-catalog.js +20 -30
- package/dist/command-catalog.js.map +1 -1
- package/dist/config-target.js +1 -1
- package/dist/config-target.js.map +1 -1
- package/dist/db-child.js +3 -10
- package/dist/db-child.js.map +1 -1
- package/dist/db-config.d.ts +2 -0
- package/dist/db-config.d.ts.map +1 -1
- package/dist/db-config.js +2 -0
- package/dist/db-config.js.map +1 -1
- package/dist/doctor.d.ts +14 -3
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +91 -6
- package/dist/doctor.js.map +1 -1
- package/dist/frontend-guidance.d.ts +19 -0
- package/dist/frontend-guidance.d.ts.map +1 -1
- package/dist/frontend-guidance.js +267 -23
- package/dist/frontend-guidance.js.map +1 -1
- package/dist/hand-built-manifest.d.ts.map +1 -1
- package/dist/hand-built-manifest.js +1 -1
- package/dist/hand-built-manifest.js.map +1 -1
- package/dist/internal/control-character.d.ts +3 -0
- package/dist/internal/control-character.d.ts.map +1 -0
- package/dist/internal/control-character.js +10 -0
- package/dist/internal/control-character.js.map +1 -0
- package/dist/internal/escape-regexp.d.ts +3 -0
- package/dist/internal/escape-regexp.d.ts.map +1 -0
- package/dist/internal/escape-regexp.js +5 -0
- package/dist/internal/escape-regexp.js.map +1 -0
- package/dist/internal/line-at.d.ts +3 -0
- package/dist/internal/line-at.d.ts.map +1 -0
- package/dist/internal/line-at.js +5 -0
- package/dist/internal/line-at.js.map +1 -0
- package/dist/internal/nifra-project.d.ts.map +1 -1
- package/dist/internal/nifra-project.js +35 -41
- package/dist/internal/nifra-project.js.map +1 -1
- package/dist/internal/posix-path.d.ts +3 -0
- package/dist/internal/posix-path.d.ts.map +1 -0
- package/dist/internal/posix-path.js +5 -0
- package/dist/internal/posix-path.js.map +1 -0
- package/dist/internal/project-specifiers.d.ts.map +1 -1
- package/dist/internal/project-specifiers.js +3 -10
- package/dist/internal/project-specifiers.js.map +1 -1
- package/dist/internal/realpath-or-self.d.ts +3 -0
- package/dist/internal/realpath-or-self.d.ts.map +1 -0
- package/dist/internal/realpath-or-self.js +11 -0
- package/dist/internal/realpath-or-self.js.map +1 -0
- package/dist/internal/record.d.ts +3 -0
- package/dist/internal/record.d.ts.map +1 -0
- package/dist/internal/record.js +5 -0
- package/dist/internal/record.js.map +1 -0
- package/dist/internal/source-facts.d.ts.map +1 -1
- package/dist/internal/source-facts.js +28 -25
- package/dist/internal/source-facts.js.map +1 -1
- package/dist/introspect.d.ts +0 -22
- package/dist/introspect.d.ts.map +1 -1
- package/dist/introspect.js +11 -151
- package/dist/introspect.js.map +1 -1
- package/dist/levels-tool.d.ts +2 -0
- package/dist/levels-tool.d.ts.map +1 -1
- package/dist/levels-tool.js +54 -64
- package/dist/levels-tool.js.map +1 -1
- package/dist/load.d.ts +6 -1
- package/dist/load.d.ts.map +1 -1
- package/dist/load.js.map +1 -1
- package/dist/local-cli.d.ts +7 -0
- package/dist/local-cli.d.ts.map +1 -1
- package/dist/local-cli.js +13 -0
- package/dist/local-cli.js.map +1 -1
- package/dist/mcp-docs-tools.d.ts +1 -1
- package/dist/mcp-docs-tools.d.ts.map +1 -1
- package/dist/mcp-docs-tools.js +46 -3
- package/dist/mcp-docs-tools.js.map +1 -1
- package/dist/mcp-http.d.ts +1 -1
- package/dist/mcp-http.js +2 -2
- package/dist/mcp-io.d.ts +16 -0
- package/dist/mcp-io.d.ts.map +1 -1
- package/dist/mcp-io.js +63 -0
- package/dist/mcp-io.js.map +1 -1
- package/dist/mcp-isolate.d.ts.map +1 -1
- package/dist/mcp-isolate.js +2 -1
- package/dist/mcp-isolate.js.map +1 -1
- package/dist/mcp-project-child.d.ts.map +1 -1
- package/dist/mcp-project-child.js +5 -12
- package/dist/mcp-project-child.js.map +1 -1
- package/dist/mcp-render.d.ts.map +1 -1
- package/dist/mcp-render.js +9 -51
- package/dist/mcp-render.js.map +1 -1
- package/dist/mcp-root.js +1 -1
- package/dist/mcp-root.js.map +1 -1
- package/dist/mcp-run.d.ts.map +1 -1
- package/dist/mcp-run.js +3 -46
- package/dist/mcp-run.js.map +1 -1
- package/dist/mcp-ws.d.ts.map +1 -1
- package/dist/mcp-ws.js +2 -18
- package/dist/mcp-ws.js.map +1 -1
- package/dist/migrate-layout.d.ts.map +1 -1
- package/dist/migrate-layout.js +36 -57
- package/dist/migrate-layout.js.map +1 -1
- package/dist/output-schemas.d.ts.map +1 -1
- package/dist/output-schemas.js +7 -7
- package/dist/output-schemas.js.map +1 -1
- package/dist/port.d.ts.map +1 -1
- package/dist/port.js +1 -2
- package/dist/port.js.map +1 -1
- package/dist/ppr-read-fix.js +2 -2
- package/dist/ppr-read-fix.js.map +1 -1
- package/dist/recipes/5.8.0.d.ts +9 -0
- package/dist/recipes/5.8.0.d.ts.map +1 -0
- package/dist/recipes/5.8.0.js +20 -0
- package/dist/recipes/5.8.0.js.map +1 -0
- package/dist/recipes/5.9.0.d.ts +10 -0
- package/dist/recipes/5.9.0.d.ts.map +1 -0
- package/dist/recipes/5.9.0.js +41 -0
- package/dist/recipes/5.9.0.js.map +1 -0
- package/dist/recipes/index.d.ts +5 -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 +9 -13
- package/dist/review.js.map +1 -1
- package/dist/rules/contract-visibility.d.ts.map +1 -1
- package/dist/rules/contract-visibility.js +3 -9
- package/dist/rules/contract-visibility.js.map +1 -1
- package/dist/rules/data-guard.d.ts.map +1 -1
- package/dist/rules/data-guard.js +3 -10
- package/dist/rules/data-guard.js.map +1 -1
- package/dist/rules/pages.d.ts.map +1 -1
- package/dist/rules/pages.js +41 -58
- package/dist/rules/pages.js.map +1 -1
- package/dist/rules/routes.d.ts.map +1 -1
- package/dist/rules/routes.js +20 -27
- package/dist/rules/routes.js.map +1 -1
- package/dist/rules/security.d.ts.map +1 -1
- package/dist/rules/security.js +206 -313
- package/dist/rules/security.js.map +1 -1
- package/dist/rules/zones.d.ts.map +1 -1
- package/dist/rules/zones.js +3 -10
- package/dist/rules/zones.js.map +1 -1
- package/dist/runtime-differences.d.ts +62 -0
- package/dist/runtime-differences.d.ts.map +1 -0
- package/dist/runtime-differences.js +222 -0
- package/dist/runtime-differences.js.map +1 -0
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +43 -43
- package/dist/sdk.js.map +1 -1
- package/dist/smoke.d.ts.map +1 -1
- package/dist/smoke.js +4 -12
- package/dist/smoke.js.map +1 -1
- package/dist/source-rewrites.d.ts +27 -0
- package/dist/source-rewrites.d.ts.map +1 -0
- package/dist/source-rewrites.js +402 -0
- package/dist/source-rewrites.js.map +1 -0
- package/dist/stylex-migrate.d.ts.map +1 -1
- package/dist/stylex-migrate.js +1 -1
- package/dist/stylex-migrate.js.map +1 -1
- package/dist/symptom-search.d.ts +5 -0
- package/dist/symptom-search.d.ts.map +1 -0
- package/dist/symptom-search.js +21 -0
- package/dist/symptom-search.js.map +1 -0
- package/dist/upgrade.d.ts +28 -3
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +153 -64
- package/dist/upgrade.js.map +1 -1
- package/dist/verification-plan.d.ts.map +1 -1
- package/dist/verification-plan.js +5 -3
- package/dist/verification-plan.js.map +1 -1
- package/docs/examples.json +32 -2
- package/docs/llms-full.txt +749 -95
- package/docs/types.json +300 -61
- package/package.json +11 -11
- package/src/agent-files.ts +4 -1
- package/src/assure-hydration.ts +2 -9
- package/src/assure.ts +3 -4
- package/src/check-scan.ts +65 -82
- package/src/check.ts +25 -23
- package/src/cli.ts +61 -13
- package/src/command-catalog.ts +22 -32
- package/src/config-target.ts +1 -1
- package/src/db-child.ts +3 -10
- package/src/db-config.ts +4 -0
- package/src/doctor.ts +128 -12
- package/src/frontend-guidance.ts +344 -25
- package/src/hand-built-manifest.ts +1 -2
- package/src/internal/control-character.ts +8 -0
- package/src/internal/escape-regexp.ts +4 -0
- package/src/internal/line-at.ts +4 -0
- package/src/internal/nifra-project.ts +39 -35
- package/src/internal/posix-path.ts +4 -0
- package/src/internal/project-specifiers.ts +3 -10
- package/src/internal/realpath-or-self.ts +10 -0
- package/src/internal/record.ts +4 -0
- package/src/internal/source-facts.ts +39 -29
- package/src/introspect.ts +16 -156
- package/src/levels-tool.ts +71 -78
- package/src/load.ts +6 -1
- package/src/local-cli.ts +12 -0
- package/src/mcp-docs-tools.ts +51 -3
- package/src/mcp-http.ts +2 -2
- package/src/mcp-io.ts +77 -0
- package/src/mcp-isolate.ts +2 -3
- package/src/mcp-project-child.ts +5 -14
- package/src/mcp-render.ts +11 -59
- package/src/mcp-root.ts +1 -1
- package/src/mcp-run.ts +5 -54
- package/src/mcp-ws.ts +2 -19
- package/src/migrate-layout.ts +52 -72
- package/src/output-schemas.ts +7 -8
- package/src/port.ts +1 -4
- package/src/ppr-read-fix.ts +2 -2
- package/src/recipes/5.8.0.ts +21 -0
- package/src/recipes/5.9.0.ts +42 -0
- package/src/recipes/index.ts +9 -0
- package/src/review.ts +12 -15
- package/src/rules/contract-visibility.ts +3 -8
- package/src/rules/data-guard.ts +3 -10
- package/src/rules/pages.ts +47 -58
- package/src/rules/routes.ts +21 -27
- package/src/rules/security.ts +224 -255
- package/src/rules/zones.ts +3 -10
- package/src/runtime-differences.ts +302 -0
- package/src/sdk.ts +55 -58
- package/src/smoke.ts +4 -13
- package/src/source-rewrites.ts +463 -0
- package/src/stylex-migrate.ts +1 -3
- package/src/symptom-search.ts +27 -0
- package/src/upgrade.ts +194 -74
- package/src/verification-plan.ts +10 -4
package/src/config-target.ts
CHANGED
|
@@ -35,7 +35,7 @@ export function writeConfigTarget(appRoot: string, target: string): string | und
|
|
|
35
35
|
const previous = found?.[2]
|
|
36
36
|
let next: string
|
|
37
37
|
if (found === null) {
|
|
38
|
-
next = `${text.replace(
|
|
38
|
+
next = `${text.replace(/(?<!\n)\n*$/, "\n")}\n// The deploy target \`nifra build\` emits; \`nifra target <t>\` switches it.\nexport const target = "${target}"\n`
|
|
39
39
|
} else {
|
|
40
40
|
// Only the quoted value changes, so a type annotation on the export survives.
|
|
41
41
|
const end = found.index + found[0].length
|
package/src/db-child.ts
CHANGED
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
import { createDevFeed } from "@nifrajs/web/dev-feed"
|
|
35
35
|
import { isSensitiveFieldName } from "@nifrajs/web/zones"
|
|
36
36
|
import { type DevDatabase, loadDevDatabase } from "./db-config.ts"
|
|
37
|
-
import { CHILD_INPUT_MAX_BYTES, readBoundedStream } from "./mcp-io.ts"
|
|
37
|
+
import { CHILD_INPUT_MAX_BYTES, protocolStdout, readBoundedStream } from "./mcp-io.ts"
|
|
38
38
|
|
|
39
39
|
/** The one operation a subprocess runs. */
|
|
40
40
|
export interface DbChildRequest {
|
|
@@ -154,7 +154,7 @@ async function runPostgres(
|
|
|
154
154
|
return isDbRefusal(schema) ? schema : { ...base, schema }
|
|
155
155
|
}
|
|
156
156
|
if (request.op === "role") {
|
|
157
|
-
const role = await postgresRoleSql(client, db)
|
|
157
|
+
const role = await postgresRoleSql(client, { ...db, redaction })
|
|
158
158
|
if (isDbRefusal(role)) return role
|
|
159
159
|
return {
|
|
160
160
|
...base,
|
|
@@ -267,14 +267,7 @@ export async function serveDbChild(
|
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
if (import.meta.main) {
|
|
270
|
-
|
|
271
|
-
const stdout = process.stdout.write.bind(process.stdout)
|
|
272
|
-
const toStderr = (...args: unknown[]): void => {
|
|
273
|
-
process.stderr.write(`${args.map((arg) => String(arg)).join(" ")}\n`)
|
|
274
|
-
}
|
|
275
|
-
console.log = toStderr
|
|
276
|
-
console.info = toStderr
|
|
277
|
-
console.debug = toStderr
|
|
270
|
+
const stdout = protocolStdout()
|
|
278
271
|
const served = await serveDbChild(
|
|
279
272
|
process.argv[2] ?? process.cwd(),
|
|
280
273
|
Bun.stdin.stream(),
|
package/src/db-config.ts
CHANGED
|
@@ -49,6 +49,8 @@ export interface DevPostgresDatabase extends DevDatabaseCommon {
|
|
|
49
49
|
readonly allowHosts: readonly string[]
|
|
50
50
|
/** Extensions or untrusted languages the role may use without the query being refused. */
|
|
51
51
|
readonly allowExtensions: readonly string[]
|
|
52
|
+
/** Functions (`name` or `schema.name`) a query may call although the function allowlist refuses them. */
|
|
53
|
+
readonly allowFunctions: readonly string[]
|
|
52
54
|
/** Schemas a query may read (default `["public"]`). */
|
|
53
55
|
readonly schemas: readonly string[]
|
|
54
56
|
}
|
|
@@ -71,6 +73,7 @@ const POSTGRES_FIELDS = new Set<string>([
|
|
|
71
73
|
"url",
|
|
72
74
|
"allowHosts",
|
|
73
75
|
"allowExtensions",
|
|
76
|
+
"allowFunctions",
|
|
74
77
|
"schemas",
|
|
75
78
|
])
|
|
76
79
|
|
|
@@ -173,6 +176,7 @@ export function parseDevDatabase(value: unknown): DevDatabase | DbRefusal {
|
|
|
173
176
|
url,
|
|
174
177
|
allowHosts: strings(fields, "allowHosts"),
|
|
175
178
|
allowExtensions: strings(fields, "allowExtensions"),
|
|
179
|
+
allowFunctions: strings(fields, "allowFunctions"),
|
|
176
180
|
schemas: fields("schemas") === undefined ? ["public"] : strings(fields, "schemas"),
|
|
177
181
|
}
|
|
178
182
|
} catch (error) {
|
package/src/doctor.ts
CHANGED
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
import { collectStaleMcpPins, type StaleMcpPin } from "./init-agents.ts"
|
|
41
41
|
import { codeUnitOrder } from "./internal/code-unit-order.ts"
|
|
42
42
|
import { createSpecifierResolver } from "./internal/project-specifiers.ts"
|
|
43
|
+
import { isRecord } from "./internal/record.ts"
|
|
43
44
|
import {
|
|
44
45
|
bunLockDir,
|
|
45
46
|
type StaleLinkLock,
|
|
@@ -226,11 +227,22 @@ export interface DoctorResult {
|
|
|
226
227
|
/**
|
|
227
228
|
* Route files that export `keepAlive` in an app where nothing names its sign-in cookie: no
|
|
228
229
|
* `identityCookies`, `rotateIdentityEpoch()` or `identityChanged()`, and either no `@nifrajs/auth`,
|
|
229
|
-
* Better Auth or Auth.js dependency or a source file (`renamedIn
|
|
230
|
-
* name of its own. A sign-out there may
|
|
231
|
-
* folded into `ok`).
|
|
230
|
+
* Better Auth or Auth.js dependency or a source file (`renamedIn`: the app's, or one in a wrapper
|
|
231
|
+
* package the app owns) that gives the session cookie a name of its own. A sign-out there may
|
|
232
|
+
* leave the previous visitor's kept pages. Advisory (never folded into `ok`).
|
|
232
233
|
*/
|
|
233
234
|
readonly keepAliveIdentity?: { readonly routes: readonly string[]; readonly renamedIn?: string }
|
|
235
|
+
/**
|
|
236
|
+
* Route files that export `keepAlive` in an app that reaches a known auth library only through a
|
|
237
|
+
* package of its own, such as a workspace wrapper (`via`, from the app's dependency down). The
|
|
238
|
+
* runtime still recognizes that library's session cookie by its default name or, for Better Auth,
|
|
239
|
+
* by the `<prefix>.session_token` suffix, so this is information, not a warning.
|
|
240
|
+
*/
|
|
241
|
+
readonly keepAliveIdentityCovered?: {
|
|
242
|
+
readonly routes: readonly string[]
|
|
243
|
+
readonly package: string
|
|
244
|
+
readonly via: readonly string[]
|
|
245
|
+
}
|
|
234
246
|
/** Static production-readiness evidence for the selected deploy target. */
|
|
235
247
|
readonly readiness?: DoctorReadiness
|
|
236
248
|
/** The explicit source boundary used by the dependency scan. */
|
|
@@ -318,9 +330,6 @@ const depNames = (pkg: Record<string, unknown>, field: string): string[] => {
|
|
|
318
330
|
: []
|
|
319
331
|
}
|
|
320
332
|
|
|
321
|
-
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
322
|
-
typeof value === "object" && value !== null && !Array.isArray(value)
|
|
323
|
-
|
|
324
333
|
const MAX_WORKSPACE_IMPORTERS = 2_048
|
|
325
334
|
function workspacePatterns(pkg: Record<string, unknown>): string[] {
|
|
326
335
|
const raw = pkg.workspaces
|
|
@@ -879,6 +888,97 @@ const IDENTITY_SIGNAL = /\b(?:identityCookies\s*:|rotateIdentityEpoch\s*\(|ident
|
|
|
879
888
|
const RENAMED_SESSION =
|
|
880
889
|
/\b(?:session_token|sessionToken)\s*:\s*\{[^}]*\bname\s*:|\bcookieName\s*:\s*["'`]/
|
|
881
890
|
|
|
891
|
+
// Below the app itself, only what a package loads at runtime is followed.
|
|
892
|
+
const AUTH_RUNTIME_FIELDS = ["dependencies", "peerDependencies", "optionalDependencies"] as const
|
|
893
|
+
// Bounds the walk over a large install; a wrapper sits a step or two from the app.
|
|
894
|
+
const MAX_AUTH_WALK = 2000
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* The known auth package nearest the app among the packages it depends on, followed through the
|
|
898
|
+
* installed and linked graph (real paths, so a workspace package and its own install count once),
|
|
899
|
+
* with the dependency chain that reaches it. The app's own dependencies are checked by the caller.
|
|
900
|
+
* A package declared but not installed - an unmet peer or optional dependency - is not reached.
|
|
901
|
+
* `renamedIn` is the first file of a source package on that chain outside the app's tree (a workspace
|
|
902
|
+
* sibling, a `file:` or `link:` package) that renames the session cookie: the app's own scan never
|
|
903
|
+
* reads it.
|
|
904
|
+
*/
|
|
905
|
+
async function reachableAuthPackage(
|
|
906
|
+
cwd: string,
|
|
907
|
+
pkg: Record<string, unknown>,
|
|
908
|
+
): Promise<
|
|
909
|
+
| {
|
|
910
|
+
readonly package: string
|
|
911
|
+
readonly via: readonly string[]
|
|
912
|
+
readonly renamedIn: string | undefined
|
|
913
|
+
}
|
|
914
|
+
| undefined
|
|
915
|
+
> {
|
|
916
|
+
let root: string
|
|
917
|
+
try {
|
|
918
|
+
root = await realpath(cwd)
|
|
919
|
+
} catch {
|
|
920
|
+
root = resolve(cwd)
|
|
921
|
+
}
|
|
922
|
+
const visited = new Set<string>([root])
|
|
923
|
+
const queue: {
|
|
924
|
+
readonly dir: string
|
|
925
|
+
readonly via: readonly string[]
|
|
926
|
+
readonly dirs: readonly string[]
|
|
927
|
+
readonly pkg: Record<string, unknown>
|
|
928
|
+
}[] = [{ dir: root, via: [], dirs: [], pkg }]
|
|
929
|
+
for (let next = 0; next < queue.length && visited.size < MAX_AUTH_WALK; next++) {
|
|
930
|
+
const current = queue[next]
|
|
931
|
+
if (current === undefined) break
|
|
932
|
+
const names = new Set<string>()
|
|
933
|
+
for (const field of next === 0 ? DEPENDENCY_FIELDS : AUTH_RUNTIME_FIELDS) {
|
|
934
|
+
for (const name of Object.keys(depRecord(current.pkg, field) ?? {})) names.add(name)
|
|
935
|
+
}
|
|
936
|
+
for (const name of [...names].sort(codeUnitOrder)) {
|
|
937
|
+
const path = resolvePackageFrom(current.dir, name)
|
|
938
|
+
if (path === undefined) continue
|
|
939
|
+
if (next > 0 && KNOWN_AUTH_PACKAGES.includes(name)) {
|
|
940
|
+
const renamedIn = await renamedInSources(root, current.dirs)
|
|
941
|
+
return { package: name, via: current.via, renamedIn }
|
|
942
|
+
}
|
|
943
|
+
if (visited.has(path)) continue
|
|
944
|
+
visited.add(path)
|
|
945
|
+
const meta = await readJson(join(path, "package.json"))
|
|
946
|
+
if (meta !== undefined) {
|
|
947
|
+
queue.push({
|
|
948
|
+
dir: path,
|
|
949
|
+
via: [...current.via, name],
|
|
950
|
+
dirs: [...current.dirs, path],
|
|
951
|
+
pkg: meta,
|
|
952
|
+
})
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
return undefined
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
async function renamedInSources(
|
|
960
|
+
root: string,
|
|
961
|
+
dirs: readonly string[],
|
|
962
|
+
): Promise<string | undefined> {
|
|
963
|
+
for (const resolved of dirs) {
|
|
964
|
+
// root is a realpath; a resolved dir can still hold a Windows 8.3 name such as RUNNER~1.
|
|
965
|
+
const dir = await realpath(resolved).catch(() => resolved)
|
|
966
|
+
if (dir.startsWith(root + sep) || dir.split(sep).includes("node_modules")) continue
|
|
967
|
+
let found: string | undefined
|
|
968
|
+
await walkSource(
|
|
969
|
+
dir,
|
|
970
|
+
(rel, content) => {
|
|
971
|
+
if (found === undefined && RENAMED_SESSION.test(content)) {
|
|
972
|
+
found = displayPath(root, join(dir, rel))
|
|
973
|
+
}
|
|
974
|
+
},
|
|
975
|
+
{ scripts: true, library: true },
|
|
976
|
+
)
|
|
977
|
+
if (found !== undefined) return found
|
|
978
|
+
}
|
|
979
|
+
return undefined
|
|
980
|
+
}
|
|
981
|
+
|
|
882
982
|
function keepAliveRoutes(cwd: string): readonly string[] {
|
|
883
983
|
const routesDir = join(cwd, "routes")
|
|
884
984
|
if (!existsSync(routesDir)) return []
|
|
@@ -958,15 +1058,24 @@ export async function collectDoctorResult(
|
|
|
958
1058
|
const lockDir = bunLockDir(cwd)
|
|
959
1059
|
const linkLocks = lockDir === undefined ? [] : staleLinkLocks(lockDir)
|
|
960
1060
|
const handBuilt = handBuiltManifests(cwd, manifestLists)
|
|
961
|
-
const
|
|
962
|
-
const
|
|
963
|
-
identitySignal || (
|
|
1061
|
+
const directAuth = KNOWN_AUTH_PACKAGES.some((name) => dependencySpec(pkg, name) !== undefined)
|
|
1062
|
+
const keptRoutes =
|
|
1063
|
+
identitySignal || (directAuth && renamedIn === undefined) ? [] : keepAliveRoutes(cwd)
|
|
1064
|
+
// A wrapper package the app owns may be what brings the auth library in.
|
|
1065
|
+
const reachedAuth =
|
|
1066
|
+
keptRoutes.length === 0 || directAuth ? undefined : await reachableAuthPackage(cwd, pkg)
|
|
1067
|
+
renamedIn ??= reachedAuth?.renamedIn
|
|
1068
|
+
const knownAuth = directAuth || reachedAuth !== undefined
|
|
964
1069
|
const keepAliveIdentity =
|
|
965
|
-
|
|
1070
|
+
keptRoutes.length === 0 || (reachedAuth !== undefined && renamedIn === undefined)
|
|
966
1071
|
? undefined
|
|
967
1072
|
: knownAuth && renamedIn !== undefined
|
|
968
|
-
? { routes:
|
|
969
|
-
: { routes:
|
|
1073
|
+
? { routes: keptRoutes, renamedIn }
|
|
1074
|
+
: { routes: keptRoutes }
|
|
1075
|
+
const keepAliveIdentityCovered =
|
|
1076
|
+
reachedAuth !== undefined && renamedIn === undefined
|
|
1077
|
+
? { routes: keptRoutes, package: reachedAuth.package, via: reachedAuth.via }
|
|
1078
|
+
: undefined
|
|
970
1079
|
// `staleDists`, `toolingDrift` and `staleMcpPins` are advisory (see DoctorResult): they never fail `ok`.
|
|
971
1080
|
return {
|
|
972
1081
|
ok:
|
|
@@ -987,6 +1096,7 @@ export async function collectDoctorResult(
|
|
|
987
1096
|
...(versionDrift !== undefined ? { versionDrift } : {}),
|
|
988
1097
|
...(handBuilt.length > 0 ? { handBuiltManifests: handBuilt } : {}),
|
|
989
1098
|
...(keepAliveIdentity !== undefined ? { keepAliveIdentity } : {}),
|
|
1099
|
+
...(keepAliveIdentityCovered !== undefined ? { keepAliveIdentityCovered } : {}),
|
|
990
1100
|
...(staleMcpPins !== undefined && staleMcpPins.files.length > 0 ? { staleMcpPins } : {}),
|
|
991
1101
|
...(lockDir !== undefined && linkLocks.length > 0
|
|
992
1102
|
? {
|
|
@@ -1203,6 +1313,12 @@ export function doctorReport(result: DoctorResult, cliVersion?: string): string[
|
|
|
1203
1313
|
" fix: name the session cookie in keepAlive.identityCookies - exported from backend/framework.ts, or passed to createWebApp in a server you write - or call identityChanged() from @nifrajs/web/client for token auth - /docs/keep-alive#sign-in\n",
|
|
1204
1314
|
)
|
|
1205
1315
|
}
|
|
1316
|
+
if (result.keepAliveIdentityCovered !== undefined) {
|
|
1317
|
+
const { routes, package: library, via } = result.keepAliveIdentityCovered
|
|
1318
|
+
lines.push(
|
|
1319
|
+
`ℹ ${routes.join(", ")} keep pages alive, and this app reaches ${library} through ${via.join(" > ")}: nifra knows its session cookie by the default name${library === "better-auth" ? " or the <prefix>.session_token suffix" : ""}, so a sign-out drops the kept pages unless that package renames the cookie outright (then name it in keepAlive.identityCookies)\n`,
|
|
1320
|
+
)
|
|
1321
|
+
}
|
|
1206
1322
|
// Advisory: the agent's MCP server is launched from these pins, so a stale one answers for an old
|
|
1207
1323
|
// release even when the CLI running doctor matches the project.
|
|
1208
1324
|
if (result.staleMcpPins !== undefined) {
|