@nifrajs/cli 2.1.0 → 2.3.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/README.md +25 -25
- package/dist/assure.d.ts +2 -2
- package/dist/assure.d.ts.map +1 -1
- package/dist/assure.js +17 -10
- package/dist/assure.js.map +1 -1
- package/dist/capabilities-tool.d.ts +7 -0
- package/dist/capabilities-tool.d.ts.map +1 -1
- package/dist/capabilities-tool.js +68 -16
- package/dist/capabilities-tool.js.map +1 -1
- package/dist/check.d.ts +64 -22
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +400 -83
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts +37 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +291 -53
- package/dist/cli.js.map +1 -1
- package/dist/diff-tool.d.ts +3 -3
- package/dist/diff-tool.js +7 -7
- package/dist/docs-search.d.ts +3 -3
- package/dist/docs-search.js +6 -6
- package/dist/doctor.d.ts +8 -4
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +74 -14
- package/dist/doctor.js.map +1 -1
- package/dist/examples.d.ts +5 -5
- package/dist/examples.js +5 -5
- package/dist/init-agents.d.ts +14 -14
- package/dist/init-agents.js +14 -14
- package/dist/internal/typescript-import.d.ts +24 -0
- package/dist/internal/typescript-import.d.ts.map +1 -0
- package/dist/internal/typescript-import.js +32 -0
- package/dist/internal/typescript-import.js.map +1 -0
- package/dist/introspect.d.ts +12 -12
- package/dist/introspect.js +24 -24
- package/dist/levels-tool.d.ts +8 -8
- package/dist/levels-tool.d.ts.map +1 -1
- package/dist/levels-tool.js +33 -30
- package/dist/levels-tool.js.map +1 -1
- package/dist/load.d.ts +17 -6
- package/dist/load.d.ts.map +1 -1
- package/dist/load.js +45 -7
- package/dist/load.js.map +1 -1
- package/dist/manifest-tool.d.ts +1 -1
- package/dist/manifest-tool.d.ts.map +1 -1
- package/dist/manifest-tool.js +4 -2
- package/dist/manifest-tool.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 +14 -10
- package/dist/mcp-docs-tools.js.map +1 -1
- package/dist/mcp-http.d.ts +5 -5
- package/dist/mcp-http.js +7 -7
- package/dist/mcp-protocol.d.ts +2 -2
- package/dist/mcp-protocol.js +2 -2
- package/dist/mcp-render.d.ts +3 -3
- package/dist/mcp-render.js +15 -7
- package/dist/mcp-render.js.map +1 -1
- package/dist/mcp-run.d.ts +2 -2
- package/dist/mcp-run.js +2 -2
- package/dist/mcp.d.ts +14 -14
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +119 -47
- package/dist/mcp.js.map +1 -1
- package/dist/openapi-tool.d.ts +1 -1
- package/dist/openapi-tool.js +2 -2
- package/dist/pipeline-guard.d.ts +83 -0
- package/dist/pipeline-guard.d.ts.map +1 -0
- package/dist/pipeline-guard.js +136 -0
- package/dist/pipeline-guard.js.map +1 -0
- package/dist/port.d.ts +9 -9
- package/dist/port.js +27 -27
- package/dist/recipes/1.8.0.d.ts +2 -2
- package/dist/recipes/1.8.0.js +5 -5
- package/dist/recipes/index.d.ts +2 -2
- package/dist/recipes/index.js +1 -1
- package/dist/scaffold.d.ts +3 -3
- package/dist/scaffold.js +8 -8
- package/dist/sync-routes.d.ts +28 -0
- package/dist/sync-routes.d.ts.map +1 -0
- package/dist/sync-routes.js +55 -0
- package/dist/sync-routes.js.map +1 -0
- package/dist/types-search.d.ts +6 -6
- package/dist/types-search.d.ts.map +1 -1
- package/dist/types-search.js +53 -8
- package/dist/types-search.js.map +1 -1
- package/dist/upgrade.d.ts +7 -7
- package/dist/upgrade.js +12 -12
- package/dist/verification.d.ts +51 -0
- package/dist/verification.d.ts.map +1 -0
- package/dist/verification.js +80 -0
- package/dist/verification.js.map +1 -0
- package/docs/examples.json +178 -88
- package/docs/llms-full.txt +1766 -766
- package/docs/types.json +2171 -2807
- package/package.json +22 -11
- package/src/assure.ts +17 -18
- package/src/capabilities-tool.ts +82 -16
- package/src/check.ts +493 -100
- package/src/cli.ts +306 -54
- package/src/diff-tool.ts +8 -8
- package/src/docs-search.ts +6 -6
- package/src/doctor.ts +81 -16
- package/src/examples.ts +7 -7
- package/src/init-agents.ts +17 -17
- package/src/internal/typescript-import.ts +33 -0
- package/src/introspect.ts +28 -28
- package/src/levels-tool.ts +37 -31
- package/src/load.ts +65 -12
- package/src/manifest-tool.ts +4 -2
- package/src/mcp-docs-tools.ts +20 -10
- package/src/mcp-http.ts +7 -7
- package/src/mcp-protocol.ts +2 -2
- package/src/mcp-render.ts +15 -7
- package/src/mcp-run.ts +2 -2
- package/src/mcp.ts +127 -47
- package/src/openapi-tool.ts +2 -2
- package/src/pipeline-guard.ts +186 -0
- package/src/port.ts +31 -31
- package/src/recipes/1.8.0.ts +5 -5
- package/src/recipes/index.ts +2 -2
- package/src/scaffold.ts +8 -8
- package/src/sync-routes.ts +69 -0
- package/src/types-search.ts +57 -8
- package/src/upgrade.ts +12 -12
- package/src/verification.ts +123 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One project verification, four commands. `nifra check`, `nifra assure`, `nifra levels`, and
|
|
3
|
+
* `nifra capabilities` are not separate audits - they are renderings of the same reflected project: the
|
|
4
|
+
* typed-contract scan, the route-assurance evaluation, and the static capability provenance. Historically
|
|
5
|
+
* each command re-derived the slice it needed, so a caller had to know which command ran which policy (and
|
|
6
|
+
* `levels` paid for the capability walk twice). `collectProjectVerification` runs each underlying policy
|
|
7
|
+
* exactly once and hands back a single value; the commands become thin formatters over subsets of it -
|
|
8
|
+
* `check`/`assure`/`levels` read their view directly, and `capabilities snapshot`/`check` read the same
|
|
9
|
+
* capability report before writing or diffing the lockfile.
|
|
10
|
+
*
|
|
11
|
+
* The typed-contract check is the one heavy pass (source walk + optional `tsc`), and `nifra assure`
|
|
12
|
+
* never needs it, so it is exposed as a lazily-invoked `check()` rather than computed up front.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { existsSync } from "node:fs"
|
|
16
|
+
import { resolve } from "node:path"
|
|
17
|
+
import {
|
|
18
|
+
type AssuranceConfig,
|
|
19
|
+
type AssuranceReport,
|
|
20
|
+
evaluateRouteAssurance,
|
|
21
|
+
} from "@nifrajs/core/assurance"
|
|
22
|
+
import {
|
|
23
|
+
type CapabilityProjectReport,
|
|
24
|
+
collectCapabilityProjectReport,
|
|
25
|
+
} from "./capabilities-tool.ts"
|
|
26
|
+
import { type CheckAssuranceContext, type CheckResult, collectCheckResult } from "./check.ts"
|
|
27
|
+
|
|
28
|
+
export interface CollectProjectVerificationOptions {
|
|
29
|
+
/** Assurance config path, default `nifra.assurance.ts`. Honored by the assurance + levels views. */
|
|
30
|
+
readonly config?: string
|
|
31
|
+
/** Skip the `tsc` pass in the check view (the agent inner-loop mode). */
|
|
32
|
+
readonly lintsOnly?: boolean
|
|
33
|
+
/** Cancels the check view's typecheck. */
|
|
34
|
+
readonly signal?: AbortSignal
|
|
35
|
+
/** Cap the check view's diagnostics (the `levels` L0 and MCP paths set this). */
|
|
36
|
+
readonly maxDiagnostics?: number
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ProjectVerification {
|
|
40
|
+
readonly cwd: string
|
|
41
|
+
/** Whether `nifra.assurance.ts` (or the requested `config` path) exists. */
|
|
42
|
+
readonly assuranceConfigPresent: boolean
|
|
43
|
+
/** The loaded assurance config, when it loaded cleanly. */
|
|
44
|
+
readonly config?: AssuranceConfig
|
|
45
|
+
/** The error from loading/evaluating the config, if any; the assurance views surface or throw it. */
|
|
46
|
+
readonly configError?: unknown
|
|
47
|
+
/** `evaluateRouteAssurance` over the config's source + policy. Present whenever {@link config} is. */
|
|
48
|
+
readonly routeAssurance?: AssuranceReport
|
|
49
|
+
/** Static capability provenance, when the config declares a capabilities policy. */
|
|
50
|
+
readonly capability?: CapabilityProjectReport
|
|
51
|
+
/**
|
|
52
|
+
* The typed-contract check (scanners + typecheck + the assurance-fed capability/manifest diagnostics).
|
|
53
|
+
* Lazy and memoized: `nifra assure` never calls it, so that command pays nothing for the source walk.
|
|
54
|
+
*/
|
|
55
|
+
check(): Promise<CheckResult>
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Run each verification policy once and return the unified value. The config is loaded (and reflected)
|
|
60
|
+
* a single time; the resulting route-assurance + capability evidence is both returned for the assurance
|
|
61
|
+
* views and fed into the check view, so nothing is computed twice.
|
|
62
|
+
*/
|
|
63
|
+
export async function collectProjectVerification(
|
|
64
|
+
cwd: string,
|
|
65
|
+
options: CollectProjectVerificationOptions = {},
|
|
66
|
+
): Promise<ProjectVerification> {
|
|
67
|
+
const { loadAssuranceConfig, DEFAULT_ASSURANCE_CONFIG } = await import("./assure.ts")
|
|
68
|
+
const configPath = resolve(cwd, options.config ?? DEFAULT_ASSURANCE_CONFIG)
|
|
69
|
+
const assuranceConfigPresent = existsSync(configPath)
|
|
70
|
+
|
|
71
|
+
let config: AssuranceConfig | undefined
|
|
72
|
+
let configError: unknown
|
|
73
|
+
let routeAssurance: AssuranceReport | undefined
|
|
74
|
+
let capability: CapabilityProjectReport | undefined
|
|
75
|
+
// One try mirrors `check`'s single catch: any failure to load or reflect the config becomes the
|
|
76
|
+
// `configError` each view then renders in its own idiom (a diagnostic, a throw, a failed rung).
|
|
77
|
+
try {
|
|
78
|
+
config = await loadAssuranceConfig(cwd, options.config)
|
|
79
|
+
routeAssurance = evaluateRouteAssurance(config.source, config.policy, {
|
|
80
|
+
...(config.capabilities !== undefined
|
|
81
|
+
? { definitions: config.capabilities.definitions }
|
|
82
|
+
: {}),
|
|
83
|
+
})
|
|
84
|
+
if (config.capabilities !== undefined) {
|
|
85
|
+
capability = await collectCapabilityProjectReport(cwd, config.source, config.capabilities)
|
|
86
|
+
}
|
|
87
|
+
} catch (error) {
|
|
88
|
+
configError = error
|
|
89
|
+
config = undefined
|
|
90
|
+
routeAssurance = undefined
|
|
91
|
+
capability = undefined
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// The check view's assurance inputs. Fed to `check()` only when no custom config path was requested,
|
|
95
|
+
// so `nifra check` (which always reads the default `nifra.assurance.ts`) and `levels` L0 keep reading
|
|
96
|
+
// exactly the config they read before; a `--config` override stays a route-assurance/levels concern.
|
|
97
|
+
const checkContext: CheckAssuranceContext = {
|
|
98
|
+
present: assuranceConfigPresent,
|
|
99
|
+
...(config !== undefined ? { config } : {}),
|
|
100
|
+
...(configError !== undefined ? { error: configError } : {}),
|
|
101
|
+
...(routeAssurance !== undefined ? { routeAssurance } : {}),
|
|
102
|
+
...(capability !== undefined ? { capability } : {}),
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
let checkResult: Promise<CheckResult> | undefined
|
|
106
|
+
return Object.freeze({
|
|
107
|
+
cwd,
|
|
108
|
+
assuranceConfigPresent,
|
|
109
|
+
...(config !== undefined ? { config } : {}),
|
|
110
|
+
...(configError !== undefined ? { configError } : {}),
|
|
111
|
+
...(routeAssurance !== undefined ? { routeAssurance } : {}),
|
|
112
|
+
...(capability !== undefined ? { capability } : {}),
|
|
113
|
+
check(): Promise<CheckResult> {
|
|
114
|
+
checkResult ??= collectCheckResult(cwd, {
|
|
115
|
+
lintsOnly: options.lintsOnly ?? false,
|
|
116
|
+
...(options.signal !== undefined ? { signal: options.signal } : {}),
|
|
117
|
+
...(options.maxDiagnostics !== undefined ? { maxDiagnostics: options.maxDiagnostics } : {}),
|
|
118
|
+
...(options.config === undefined ? { assurance: checkContext } : {}),
|
|
119
|
+
})
|
|
120
|
+
return checkResult
|
|
121
|
+
},
|
|
122
|
+
})
|
|
123
|
+
}
|