@nifrajs/cli 2.7.1 → 2.8.1
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/dist/check.d.ts +3 -1
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +178 -19
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +42 -55
- package/dist/cli.js.map +1 -1
- package/dist/dev-bun-config.d.ts +36 -0
- package/dist/dev-bun-config.d.ts.map +1 -0
- package/dist/dev-bun-config.js +179 -0
- package/dist/dev-bun-config.js.map +1 -0
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +4 -1
- package/dist/doctor.js.map +1 -1
- package/dist/mcp-app-tool.d.ts +1 -1
- package/dist/mcp-app-tool.d.ts.map +1 -1
- package/dist/mcp-app-tool.js +8 -4
- package/dist/mcp-app-tool.js.map +1 -1
- package/dist/mcp-docs-tools.js +1 -1
- package/dist/mcp-docs-tools.js.map +1 -1
- package/dist/mcp-http.d.ts +3 -3
- package/dist/mcp-http.d.ts.map +1 -1
- package/dist/mcp-http.js +4 -4
- package/dist/mcp-http.js.map +1 -1
- package/docs/llms-full.txt +126 -6
- package/docs/types.json +11 -4
- package/package.json +9 -9
- package/src/check.ts +192 -19
- package/src/cli.ts +47 -60
- package/src/dev-bun-config.ts +204 -0
- package/src/doctor.ts +19 -6
- package/src/mcp-app-tool.ts +8 -4
- package/src/mcp-docs-tools.ts +1 -1
- package/src/mcp-http.ts +4 -4
package/src/doctor.ts
CHANGED
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
* declared by the package that imports it (for `tsc` and for that package to install on its own) even
|
|
10
10
|
* when a monorepo would hoist it. Relative paths, runtime builtins (node core, `node:`/`bun:`, `bun`),
|
|
11
11
|
* the package's own name, and tsconfig `paths` aliases are excluded - none of them are npm deps.
|
|
12
|
+
*
|
|
13
|
+
* The diff is against DECLARED dependency sets only; what happens to be installed on disk is never
|
|
14
|
+
* consulted. That is the point: a package pulled in transitively by some other dependency resolves fine
|
|
15
|
+
* locally while no manifest declares it, so resolvability is not evidence of declaration. The scan
|
|
16
|
+
* therefore also covers `*.test.ts`/`*.spec.ts`, which `nifra check` skips - `tsc` compiles them, so an
|
|
17
|
+
* undeclared import there fails a clean `bun install --frozen-lockfile` build just the same.
|
|
12
18
|
*/
|
|
13
19
|
import type { Dirent } from "node:fs"
|
|
14
20
|
import { readdir, realpath, stat } from "node:fs/promises"
|
|
@@ -679,12 +685,19 @@ export async function collectDoctorResult(cwd: string): Promise<DoctorResult> {
|
|
|
679
685
|
const scopes = await doctorPackageScopes(cwd, pkg)
|
|
680
686
|
|
|
681
687
|
const findings: DoctorFinding[] = []
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
+
// `includeTests`: tests are part of the typechecked surface, so an import they declare nowhere is a
|
|
689
|
+
// real break. Excluding them is what let an undeclared `zod` in a `*.test.ts` pass doctor, pass a
|
|
690
|
+
// hoisted local `tsc`, and then fail CI on a clean install with `TS2307: Cannot find module 'zod'`.
|
|
691
|
+
await walkSource(
|
|
692
|
+
cwd,
|
|
693
|
+
(rel, content) => {
|
|
694
|
+
const scope = scopeForFile(scopes, rel)
|
|
695
|
+
for (const f of scanUndeclaredImports(rel, content, scope.declared, scope.isAlias)) {
|
|
696
|
+
findings.push({ file: f.file, line: f.line, package: f.snippet })
|
|
697
|
+
}
|
|
698
|
+
},
|
|
699
|
+
{ includeTests: true },
|
|
700
|
+
)
|
|
688
701
|
findings.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line)
|
|
689
702
|
const duplicateInstalls = await collectDuplicateInstalls(cwd, pkg)
|
|
690
703
|
const staleDists = await collectStaleWorkspaceDists(cwd, pkg)
|
package/src/mcp-app-tool.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `
|
|
2
|
+
* The `nifra_gallery` MCP tool: nifra's verified code examples as an MCP Apps widget. It returns the
|
|
3
3
|
* examples as `structuredContent`, rendered by the {@link examplesWidget} `ui://` widget in MCP Apps hosts
|
|
4
4
|
* (ChatGPT Apps, MCPJam, Goose); text-only hosts still get the example names as plain text. Part of the
|
|
5
5
|
* public docs-MCP tool set (served by `handleMcpHttp`), so every self-host gets it from one definition.
|
|
@@ -50,10 +50,14 @@ export const examplesWidget = defineMcpWidget({
|
|
|
50
50
|
/** The widget-backed tool. `loadExamples` is injected (disk on the CLI, cached fetch on the edge). */
|
|
51
51
|
export function examplesAppTool(loadExamples: () => Promise<Example[] | undefined>): McpTool {
|
|
52
52
|
return defineMcpTool({
|
|
53
|
-
name: "
|
|
54
|
-
annotations: {
|
|
53
|
+
name: "nifra_gallery",
|
|
54
|
+
annotations: {
|
|
55
|
+
title: "Browse the nifra example gallery",
|
|
56
|
+
readOnlyHint: true,
|
|
57
|
+
openWorldHint: false,
|
|
58
|
+
},
|
|
55
59
|
description:
|
|
56
|
-
"
|
|
60
|
+
"Open an interactive, filterable gallery of ALL of nifra's verified code examples (MCP Apps widget) - for browsing and discovering what exists. NOT for fetching one snippet as text: use nifra_example for that. Pass query to pre-filter; the widget also filters client-side.",
|
|
57
61
|
inputSchema: {
|
|
58
62
|
type: "object",
|
|
59
63
|
properties: { query: { type: "string", description: "Pre-filter examples by keyword." } },
|
package/src/mcp-docs-tools.ts
CHANGED
|
@@ -58,7 +58,7 @@ export function docsTools(
|
|
|
58
58
|
openWorldHint: false,
|
|
59
59
|
},
|
|
60
60
|
description:
|
|
61
|
-
'Get a VERIFIED, copy-pasteable nifra code example for a task - auth route, file upload, ISR page, loader/action, typed client, SSE, deployment, etc. Every snippet is typechecked against the installed nifra version, so it compiles as-is. PREFER THIS over writing nifra code from memory (training data drifts). Call with no query for the grouped index; pass query (e.g. "protected route", "upload", "isr revalidate") for matching snippets.',
|
|
61
|
+
'Get a VERIFIED, copy-pasteable nifra code example for a task - auth route, file upload, ISR page, loader/action, typed client, SSE, deployment, etc. Every snippet is typechecked against the installed nifra version, so it compiles as-is. PREFER THIS over writing nifra code from memory (training data drifts). Returns code as TEXT for direct use; to visually browse the whole example set instead, use nifra_gallery. Call with no query for the grouped index; pass query (e.g. "protected route", "upload", "isr revalidate") for matching snippets.',
|
|
62
62
|
inputSchema: {
|
|
63
63
|
type: "object",
|
|
64
64
|
properties: {
|
package/src/mcp-http.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The PUBLIC nifra docs MCP - Streamable-HTTP transport exposing the project-INDEPENDENT tools
|
|
3
|
-
* (`nifra_docs`, `nifra_example`, `nifra_types`, `nifra_learn` + the `
|
|
3
|
+
* (`nifra_docs`, `nifra_example`, `nifra_types`, `nifra_learn` + the `nifra_gallery` MCP Apps widget)
|
|
4
4
|
* so any remote AI agent can learn nifra without a local checkout. They read the bundled corpus
|
|
5
5
|
* (llms-full.txt / examples.json / types.json shipped in this package) and ignore `cwd`, so they reuse the
|
|
6
6
|
* exact definitions from {@link projectTools} - one source, no drift.
|
|
@@ -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 = "2.
|
|
32
|
+
const VERSION = "2.8.1"
|
|
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 =>
|
|
@@ -38,7 +38,7 @@ const docsHealth = (tools: McpTool[]): string =>
|
|
|
38
38
|
.join(", ")}.`
|
|
39
39
|
|
|
40
40
|
/** The project-independent tools, reading the package's bundled corpus from disk (CLI use): the text
|
|
41
|
-
* docs tools plus the `
|
|
41
|
+
* docs tools plus the `nifra_gallery` MCP Apps widget tool. */
|
|
42
42
|
export function publicDocsTools(): McpTool[] {
|
|
43
43
|
return [
|
|
44
44
|
...docsTools(loadDocsCorpus, loadExamplesCorpus, loadTypesCorpus),
|
|
@@ -60,7 +60,7 @@ export function respondMcpHttp(
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/** The CLI HTTP handler: serves the disk-backed corpus tools + registers the examples widget's `ui://`
|
|
63
|
-
* resource so MCP Apps hosts can render `
|
|
63
|
+
* resource so MCP Apps hosts can render `nifra_gallery`. (`nifra docs-mcp` / `bun run` this file.) */
|
|
64
64
|
export function handleMcpHttp(request: Request): Promise<Response> {
|
|
65
65
|
return respondMcpHttp(request, publicDocsTools(), {
|
|
66
66
|
features: {
|