@nanisoft/prism-mcp-server 0.2.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/LICENSE +21 -0
- package/dist/factory.d.ts +31 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/factory.js +33 -0
- package/dist/factory.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/lookup.d.ts +68 -0
- package/dist/lookup.d.ts.map +1 -0
- package/dist/lookup.js +113 -0
- package/dist/lookup.js.map +1 -0
- package/dist/render.d.ts +48 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +156 -0
- package/dist/render.js.map +1 -0
- package/dist/search.d.ts +34 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +68 -0
- package/dist/search.js.map +1 -0
- package/dist/store.d.ts +62 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +80 -0
- package/dist/store.js.map +1 -0
- package/dist/tools.d.ts +22 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +120 -0
- package/dist/tools.js.map +1 -0
- package/dist/version.d.ts +11 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +11 -0
- package/dist/version.js.map +1 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 NaniSoft
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pure, transport-agnostic factory (ADR-0004): tool logic written once
|
|
3
|
+
* here, served by any transport. The site Worker wires it through
|
|
4
|
+
* `createMcpHandler(factory)`; a stdio-only client bridges with
|
|
5
|
+
* `npx mcp-remote` — there is deliberately no second implementation.
|
|
6
|
+
*
|
|
7
|
+
* The factory runs per request on the Worker lane, so the lookup maps are
|
|
8
|
+
* built inside it (never at isolate scope — ticket 05's startup-limit rule).
|
|
9
|
+
*/
|
|
10
|
+
import { McpServer } from '@modelcontextprotocol/server';
|
|
11
|
+
import { type PrismDocsStore } from './store.js';
|
|
12
|
+
export interface PrismMcpServerOptions {
|
|
13
|
+
/**
|
|
14
|
+
* The corpus build date (`YYYY-MM-DD`) for the `list_items` header.
|
|
15
|
+
*
|
|
16
|
+
* `PrismDocsStore` carries no build date (ADR-0004 §5 fixes the interface and
|
|
17
|
+
* prism-llms emits exactly those fields), so the bundler supplies this when
|
|
18
|
+
* it knows one; when absent the header simply states version + counts rather
|
|
19
|
+
* than inventing a date. If prism-llms grows a `built` field, render it from
|
|
20
|
+
* the store and retire this option.
|
|
21
|
+
*/
|
|
22
|
+
readonly built?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Build an `McpServer` with the eight Prism tools over `docs`. Pure: reads
|
|
26
|
+
* `docs`, touches no I/O, registers no transport. The store guard runs here at
|
|
27
|
+
* the door as well — callers that bypass their own validation get a precise
|
|
28
|
+
* `TypeError` naming the field, not a deep tool failure.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createPrismMcpServer(docs: PrismDocsStore, options?: PrismMcpServerOptions): McpServer;
|
|
31
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAIzD,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAGtE,MAAM,WAAW,qBAAqB;IACpC;;;;;;;;OAQG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,GAAE,qBAA0B,GAAG,SAAS,CAWzG"}
|
package/dist/factory.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pure, transport-agnostic factory (ADR-0004): tool logic written once
|
|
3
|
+
* here, served by any transport. The site Worker wires it through
|
|
4
|
+
* `createMcpHandler(factory)`; a stdio-only client bridges with
|
|
5
|
+
* `npx mcp-remote` — there is deliberately no second implementation.
|
|
6
|
+
*
|
|
7
|
+
* The factory runs per request on the Worker lane, so the lookup maps are
|
|
8
|
+
* built inside it (never at isolate scope — ticket 05's startup-limit rule).
|
|
9
|
+
*/
|
|
10
|
+
import { McpServer } from '@modelcontextprotocol/server';
|
|
11
|
+
import { createItemLookup, createPageLookup, createThemeLookup } from './lookup.js';
|
|
12
|
+
import { registerPrismTools } from './tools.js';
|
|
13
|
+
import { parsePrismDocsStore } from './store.js';
|
|
14
|
+
import { SERVER_NAME, SERVER_VERSION } from './version.js';
|
|
15
|
+
/**
|
|
16
|
+
* Build an `McpServer` with the eight Prism tools over `docs`. Pure: reads
|
|
17
|
+
* `docs`, touches no I/O, registers no transport. The store guard runs here at
|
|
18
|
+
* the door as well — callers that bypass their own validation get a precise
|
|
19
|
+
* `TypeError` naming the field, not a deep tool failure.
|
|
20
|
+
*/
|
|
21
|
+
export function createPrismMcpServer(docs, options = {}) {
|
|
22
|
+
const store = parsePrismDocsStore(docs);
|
|
23
|
+
const server = new McpServer({ name: SERVER_NAME, version: SERVER_VERSION });
|
|
24
|
+
registerPrismTools(server, {
|
|
25
|
+
docs: store,
|
|
26
|
+
items: createItemLookup(store.items),
|
|
27
|
+
pages: createPageLookup(store.pages, store.baseUrl),
|
|
28
|
+
themes: createThemeLookup(store.themes),
|
|
29
|
+
built: options.built,
|
|
30
|
+
});
|
|
31
|
+
return server;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAuB,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAe3D;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAoB,EAAE,OAAO,GAA0B,EAAE;IAC5F,MAAM,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC;IAC7E,kBAAkB,CAAC,MAAM,EAAE;QACzB,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC;QACpC,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC;QACnD,MAAM,EAAE,iBAAiB,CAAC,KAAK,CAAC,MAAM,CAAC;QACvC,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@nanisoft/prism-mcp-server` — the Prism MCP tool surface (ADR-0004).
|
|
3
|
+
*
|
|
4
|
+
* Transport-free: this package exports the pure `createPrismMcpServer(docs)`
|
|
5
|
+
* factory plus the `PrismDocsStore` corpus contract it reads (this package is
|
|
6
|
+
* that interface's canonical home — the consumer). It imports nothing from any
|
|
7
|
+
* other workspace package at runtime; apps/site bundles the factory together
|
|
8
|
+
* with `@nanisoft/prism-llms`' `data.json` at build time.
|
|
9
|
+
*/
|
|
10
|
+
export { createPrismMcpServer, type PrismMcpServerOptions } from './factory.js';
|
|
11
|
+
export { parsePrismDocsStore } from './store.js';
|
|
12
|
+
export type { PrismDocsStore, PrismDocsItem, PrismDocsPage, PrismDocsTheme } from './store.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,oBAAoB,EAAE,KAAK,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@nanisoft/prism-mcp-server` — the Prism MCP tool surface (ADR-0004).
|
|
3
|
+
*
|
|
4
|
+
* Transport-free: this package exports the pure `createPrismMcpServer(docs)`
|
|
5
|
+
* factory plus the `PrismDocsStore` corpus contract it reads (this package is
|
|
6
|
+
* that interface's canonical home — the consumer). It imports nothing from any
|
|
7
|
+
* other workspace package at runtime; apps/site bundles the factory together
|
|
8
|
+
* with `@nanisoft/prism-llms`' `data.json` at build time.
|
|
9
|
+
*/
|
|
10
|
+
export { createPrismMcpServer } from './factory.js';
|
|
11
|
+
export { parsePrismDocsStore } from './store.js';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,oBAAoB,EAA8B,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/lookup.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Case-insensitive resolution over the bundled corpus, with did-you-mean
|
|
3
|
+
* suggestions on a miss (ADR-0004 §2: lookups are case-insensitive and a miss
|
|
4
|
+
* returns the closest matches plus a browse pointer — never a throw).
|
|
5
|
+
*
|
|
6
|
+
* Maps are built once per `createPrismMcpServer()` call — per request on the
|
|
7
|
+
* Worker lane, never at isolate scope (ticket 05's startup-limit rule).
|
|
8
|
+
*/
|
|
9
|
+
import type { PrismDocsItem, PrismDocsPage, PrismDocsTheme } from './store.js';
|
|
10
|
+
/** One catalog item kind — the `kind` parameter shared by the item tools. */
|
|
11
|
+
export type ItemKind = PrismDocsItem['kind'];
|
|
12
|
+
/** Order the catalog tools group and count kinds in. */
|
|
13
|
+
export declare const ITEM_KINDS: readonly ItemKind[];
|
|
14
|
+
/** The theme atom a bare `get_theme_doc()` answers with. */
|
|
15
|
+
export declare const DEFAULT_PACK = "blue";
|
|
16
|
+
export declare const DEFAULT_MODE = "light";
|
|
17
|
+
/** Smallest-edit-distance suggestions, closest and shortest first. */
|
|
18
|
+
export declare function didYouMean(query: string, candidates: readonly string[], limit?: number): string[];
|
|
19
|
+
/** What resolving an item name produced. */
|
|
20
|
+
export type ItemMatch = {
|
|
21
|
+
readonly status: 'ok';
|
|
22
|
+
readonly item: PrismDocsItem;
|
|
23
|
+
} | {
|
|
24
|
+
readonly status: 'kind-mismatch';
|
|
25
|
+
readonly item: PrismDocsItem;
|
|
26
|
+
} | {
|
|
27
|
+
readonly status: 'miss';
|
|
28
|
+
readonly suggestions: readonly string[];
|
|
29
|
+
};
|
|
30
|
+
export interface ItemLookup {
|
|
31
|
+
/** Every item name, in corpus order — the suggestion pool and catalog input. */
|
|
32
|
+
readonly names: readonly string[];
|
|
33
|
+
find(name: string, kind?: ItemKind): ItemMatch;
|
|
34
|
+
suggest(name: string): readonly string[];
|
|
35
|
+
}
|
|
36
|
+
export declare function createItemLookup(items: readonly PrismDocsItem[]): ItemLookup;
|
|
37
|
+
export interface PageLookup {
|
|
38
|
+
/** Every page url, in corpus order. */
|
|
39
|
+
readonly urls: readonly string[];
|
|
40
|
+
find(url: string): PrismDocsPage | undefined;
|
|
41
|
+
suggest(url: string): readonly string[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Site-pathname lookup (`/docs/theming`), tolerant of case, trailing slashes,
|
|
45
|
+
* and absolute site URLs (`https://prism.nanisoft.com/docs/theming`).
|
|
46
|
+
*/
|
|
47
|
+
export declare function createPageLookup(pages: readonly PrismDocsPage[], baseUrl: string): PageLookup;
|
|
48
|
+
export interface ThemeLookup {
|
|
49
|
+
/** Every theme-atom slug, in corpus order. */
|
|
50
|
+
readonly slugs: readonly string[];
|
|
51
|
+
find(pack: string, mode: string): PrismDocsTheme | undefined;
|
|
52
|
+
suggest(slug: string): readonly string[];
|
|
53
|
+
}
|
|
54
|
+
/** Theme atoms are slugged `<pack>-<mode>` (prism-llms emits four). */
|
|
55
|
+
export declare const themeSlug: (pack: string, mode: string) => string;
|
|
56
|
+
export declare function createThemeLookup(themes: readonly PrismDocsTheme[]): ThemeLookup;
|
|
57
|
+
/** Resolve which example's source `get_item_source` should return. */
|
|
58
|
+
export type ExampleMatch = {
|
|
59
|
+
readonly status: 'ok';
|
|
60
|
+
readonly example: NonNullable<PrismDocsItem['examples']>[number];
|
|
61
|
+
} | {
|
|
62
|
+
readonly status: 'none';
|
|
63
|
+
} | {
|
|
64
|
+
readonly status: 'miss';
|
|
65
|
+
readonly suggestions: readonly string[];
|
|
66
|
+
};
|
|
67
|
+
export declare function resolveExample(item: PrismDocsItem, slug?: string): ExampleMatch;
|
|
68
|
+
//# sourceMappingURL=lookup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../src/lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE/E,6EAA6E;AAC7E,MAAM,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;AAE7C,wDAAwD;AACxD,eAAO,MAAM,UAAU,EAAE,SAAS,QAAQ,EAAmC,CAAC;AAE9E,4DAA4D;AAC5D,eAAO,MAAM,YAAY,SAAS,CAAC;AACnC,eAAO,MAAM,YAAY,UAAU,CAAC;AAKpC,sEAAsE;AACtE,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,SAAI,GAAG,MAAM,EAA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C7D,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;CAC1C;AAED,uEAAuE;AACvE,eAAO,MAAM,SAAS,SAAU,MAAM,QAAQ,MAAM,KAAG,MAA2B,CAAC;AAEnF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,GAAG,WAAW,CAQhF;AAED,sEAAsE;AACtE,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;CAAE,GAC3F;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC3B;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAEzE,wBAAgB,cAAc,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,YAAY,CAS/E"}
|
package/dist/lookup.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Case-insensitive resolution over the bundled corpus, with did-you-mean
|
|
3
|
+
* suggestions on a miss (ADR-0004 §2: lookups are case-insensitive and a miss
|
|
4
|
+
* returns the closest matches plus a browse pointer — never a throw).
|
|
5
|
+
*
|
|
6
|
+
* Maps are built once per `createPrismMcpServer()` call — per request on the
|
|
7
|
+
* Worker lane, never at isolate scope (ticket 05's startup-limit rule).
|
|
8
|
+
*/
|
|
9
|
+
/** Order the catalog tools group and count kinds in. */
|
|
10
|
+
export const ITEM_KINDS = ['component', 'block', 'page'];
|
|
11
|
+
/** The theme atom a bare `get_theme_doc()` answers with. */
|
|
12
|
+
export const DEFAULT_PACK = 'blue';
|
|
13
|
+
export const DEFAULT_MODE = 'light';
|
|
14
|
+
/** Lower-cased, trimmed lookup key. */
|
|
15
|
+
const fold = (value) => value.trim().toLowerCase();
|
|
16
|
+
/** Smallest-edit-distance suggestions, closest and shortest first. */
|
|
17
|
+
export function didYouMean(query, candidates, limit = 3) {
|
|
18
|
+
const target = fold(query);
|
|
19
|
+
return candidates
|
|
20
|
+
.map((candidate) => {
|
|
21
|
+
const folded = fold(candidate);
|
|
22
|
+
// A substring hit is a better lead than its raw edit distance suggests.
|
|
23
|
+
const distance = folded.includes(target) ? Math.min(levenshtein(target, folded), 1) : levenshtein(target, folded);
|
|
24
|
+
return { candidate, distance };
|
|
25
|
+
})
|
|
26
|
+
.filter((entry) => entry.distance <= 3)
|
|
27
|
+
.sort((a, b) => a.distance - b.distance || a.candidate.length - b.candidate.length)
|
|
28
|
+
.slice(0, limit)
|
|
29
|
+
.map((entry) => entry.candidate);
|
|
30
|
+
}
|
|
31
|
+
/** Classic two-row Levenshtein distance, case-folded by the caller. */
|
|
32
|
+
function levenshtein(a, b) {
|
|
33
|
+
if (a === b)
|
|
34
|
+
return 0;
|
|
35
|
+
if (a.length === 0)
|
|
36
|
+
return b.length;
|
|
37
|
+
if (b.length === 0)
|
|
38
|
+
return a.length;
|
|
39
|
+
let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
|
|
40
|
+
for (let i = 1; i <= a.length; i += 1) {
|
|
41
|
+
const current = [i];
|
|
42
|
+
for (let j = 1; j <= b.length; j += 1) {
|
|
43
|
+
const substitution = (previous[j - 1] ?? 0) + (a[i - 1] === b[j - 1] ? 0 : 1);
|
|
44
|
+
current.push(Math.min((previous[j] ?? 0) + 1, (current[j - 1] ?? 0) + 1, substitution));
|
|
45
|
+
}
|
|
46
|
+
previous = current;
|
|
47
|
+
}
|
|
48
|
+
return previous[b.length] ?? a.length + b.length;
|
|
49
|
+
}
|
|
50
|
+
export function createItemLookup(items) {
|
|
51
|
+
const byKey = new Map(items.map((item) => [fold(item.name), item]));
|
|
52
|
+
const names = items.map((item) => item.name);
|
|
53
|
+
return {
|
|
54
|
+
names,
|
|
55
|
+
find(name, kind) {
|
|
56
|
+
const item = byKey.get(fold(name));
|
|
57
|
+
if (!item)
|
|
58
|
+
return { status: 'miss', suggestions: didYouMean(name, names) };
|
|
59
|
+
// `kind` is a disambiguator, not a filter: a wrong one is a miss the
|
|
60
|
+
// agent must hear about, not a silent hit for the wrong entity.
|
|
61
|
+
if (kind && item.kind !== kind)
|
|
62
|
+
return { status: 'kind-mismatch', item };
|
|
63
|
+
return { status: 'ok', item };
|
|
64
|
+
},
|
|
65
|
+
suggest: (name) => didYouMean(name, names),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Site-pathname lookup (`/docs/theming`), tolerant of case, trailing slashes,
|
|
70
|
+
* and absolute site URLs (`https://prism.nanisoft.com/docs/theming`).
|
|
71
|
+
*/
|
|
72
|
+
export function createPageLookup(pages, baseUrl) {
|
|
73
|
+
const origin = baseUrl.replace(/\/+$/, '');
|
|
74
|
+
const keyOf = (url) => {
|
|
75
|
+
let path = url.trim();
|
|
76
|
+
if (path.toLowerCase().startsWith(origin.toLowerCase()))
|
|
77
|
+
path = path.slice(origin.length) || '/';
|
|
78
|
+
if (path.length > 1)
|
|
79
|
+
path = path.replace(/\/+$/, '');
|
|
80
|
+
return fold(path);
|
|
81
|
+
};
|
|
82
|
+
const byKey = new Map(pages.map((page) => [keyOf(page.url), page]));
|
|
83
|
+
const urls = pages.map((page) => page.url);
|
|
84
|
+
return {
|
|
85
|
+
urls,
|
|
86
|
+
find: (url) => byKey.get(keyOf(url)),
|
|
87
|
+
suggest: (url) => didYouMean(keyOf(url), urls),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** Theme atoms are slugged `<pack>-<mode>` (prism-llms emits four). */
|
|
91
|
+
export const themeSlug = (pack, mode) => `${pack}-${mode}`;
|
|
92
|
+
export function createThemeLookup(themes) {
|
|
93
|
+
const byKey = new Map(themes.map((theme) => [fold(theme.slug), theme]));
|
|
94
|
+
const slugs = themes.map((theme) => theme.slug);
|
|
95
|
+
return {
|
|
96
|
+
slugs,
|
|
97
|
+
find: (pack, mode) => byKey.get(fold(themeSlug(pack, mode))),
|
|
98
|
+
suggest: (slug) => didYouMean(slug, slugs),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export function resolveExample(item, slug) {
|
|
102
|
+
const examples = item.examples ?? [];
|
|
103
|
+
if (examples.length === 0)
|
|
104
|
+
return { status: 'none' };
|
|
105
|
+
if (slug === undefined)
|
|
106
|
+
return { status: 'ok', example: examples[0] };
|
|
107
|
+
const byKey = new Map(examples.map((example) => [fold(example.slug), example]));
|
|
108
|
+
const example = byKey.get(fold(slug));
|
|
109
|
+
if (example)
|
|
110
|
+
return { status: 'ok', example };
|
|
111
|
+
return { status: 'miss', suggestions: didYouMean(slug, examples.map((entry) => entry.slug)) };
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=lookup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookup.js","sourceRoot":"","sources":["../src/lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,wDAAwD;AACxD,MAAM,CAAC,MAAM,UAAU,GAAwB,CAAC,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAE9E,4DAA4D;AAC5D,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC;AACnC,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC;AAEpC,uCAAuC;AACvC,MAAM,IAAI,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAEnE,sEAAsE;AACtE,MAAM,UAAU,UAAU,CAAC,KAAa,EAAE,UAA6B,EAAE,KAAK,GAAG,CAAC;IAChF,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3B,OAAO,UAAU;SACd,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;Q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,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;IACrC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACrD,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAE,EAAE,CAAC;IAEvE,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAU,CAAC,CAAC,CAAC;IACzF,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACtC,IAAI,OAAO;QAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;AAChG,CAAC"}
|
package/dist/render.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The markdown every tool answers with — the corpus is Markdown, so JSON
|
|
3
|
+
* envelopes would only add tokens and quoting (ADR-0004 §2). All of these are
|
|
4
|
+
* pure string builders over already-resolved data; lookup/search logic lives
|
|
5
|
+
* elsewhere. Result text always prints the next call to make (§7).
|
|
6
|
+
*/
|
|
7
|
+
import type { PrismDocsItem, PrismDocsPage, PrismDocsStore, PrismDocsTheme } from './store.js';
|
|
8
|
+
import { type ItemKind } from './lookup.js';
|
|
9
|
+
import type { SearchHit } from './search.js';
|
|
10
|
+
/** The one import rule every description and every miss carries. */
|
|
11
|
+
export declare const IMPORT_RULE = "Always import from '@nanisoft/prism-ui', never from antd directly.";
|
|
12
|
+
/**
|
|
13
|
+
* `list_items` — the cold-start catalog. The header line carries the corpus
|
|
14
|
+
* version (mismatch detection) and, when the bundler supplies one, the build
|
|
15
|
+
* date; pass-throughs are marked with their antd base so the delegation seam
|
|
16
|
+
* is visible before any per-item call.
|
|
17
|
+
*/
|
|
18
|
+
export declare function catalogMarkdown(docs: PrismDocsStore, kind?: ItemKind, built?: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* `get_item_doc` — the generator's page verbatim (usage rules, props, example,
|
|
21
|
+
* the `> Extends:` seam), plus at most one steering footer built from the data.
|
|
22
|
+
*/
|
|
23
|
+
export declare function itemDocMarkdown(item: PrismDocsItem): string;
|
|
24
|
+
/**
|
|
25
|
+
* `get_item_props` — only the Prism-added delta. A pass-through's answer *is*
|
|
26
|
+
* the routing instruction (ADR-0004 §4: plasma's `_No additional props…_` line
|
|
27
|
+
* is the switch-servers signal).
|
|
28
|
+
*/
|
|
29
|
+
export declare function itemPropsMarkdown(item: PrismDocsItem): string;
|
|
30
|
+
/** `get_item_source` — the documented example, verbatim, in one fenced block. */
|
|
31
|
+
export declare function itemSourceMarkdown(item: PrismDocsItem, example: {
|
|
32
|
+
readonly slug: string;
|
|
33
|
+
readonly title?: string;
|
|
34
|
+
readonly code: string;
|
|
35
|
+
}): string;
|
|
36
|
+
/** `get_theme_doc` — the pack × mode atom verbatim, plus the sibling slugs. */
|
|
37
|
+
export declare function themeMarkdown(theme: PrismDocsTheme, all: readonly PrismDocsTheme[]): string;
|
|
38
|
+
/** `list_pages` — the site's llms.txt body as an index. */
|
|
39
|
+
export declare function pagesIndexMarkdown(pages: readonly PrismDocsPage[], baseUrl: string): string;
|
|
40
|
+
/** `get_page` — the prerendered page verbatim, cited back to the site. */
|
|
41
|
+
export declare function pageMarkdown(page: PrismDocsPage, baseUrl: string): string;
|
|
42
|
+
/** `search_docs` — ranked hits, each printing its own next call. */
|
|
43
|
+
export declare function searchResultsMarkdown(query: string, hits: readonly SearchHit[]): string;
|
|
44
|
+
/** A lookup miss: the closest names plus the browse pointer, as an error. */
|
|
45
|
+
export declare function missMarkdown(target: string, suggestions: readonly string[], browseHint: string): string;
|
|
46
|
+
/** A name hit whose `kind` argument pointed somewhere else. */
|
|
47
|
+
export declare function kindMismatchMarkdown(item: PrismDocsItem, requested: ItemKind): string;
|
|
48
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC/F,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,oEAAoE;AACpE,eAAO,MAAM,WAAW,uEAAuE,CAAC;AAOhG;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAqB7F;AAOD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAM3D;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAoB7D;AAED,iFAAiF;AACjF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAelJ;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,CAI3F;AAED,2DAA2D;AAC3D,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAc3F;AAED,0EAA0E;AAC1E,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED,oEAAoE;AACpE,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,SAAS,EAAE,GAAG,MAAM,CAavF;AAED,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAKvG;AAED,+DAA+D;AAC/D,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,GAAG,MAAM,CAErF"}
|
package/dist/render.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The markdown every tool answers with — the corpus is Markdown, so JSON
|
|
3
|
+
* envelopes would only add tokens and quoting (ADR-0004 §2). All of these are
|
|
4
|
+
* pure string builders over already-resolved data; lookup/search logic lives
|
|
5
|
+
* elsewhere. Result text always prints the next call to make (§7).
|
|
6
|
+
*/
|
|
7
|
+
import { ITEM_KINDS } from './lookup.js';
|
|
8
|
+
/** The one import rule every description and every miss carries. */
|
|
9
|
+
export const IMPORT_RULE = "Always import from '@nanisoft/prism-ui', never from antd directly.";
|
|
10
|
+
const KIND_LABEL = { component: 'component', block: 'block', page: 'page' };
|
|
11
|
+
const KIND_HEADING = { component: 'Components', block: 'Blocks', page: 'Pages' };
|
|
12
|
+
const plural = (count, noun) => (count === 1 ? `1 ${noun}` : `${count} ${noun}s`);
|
|
13
|
+
/**
|
|
14
|
+
* `list_items` — the cold-start catalog. The header line carries the corpus
|
|
15
|
+
* version (mismatch detection) and, when the bundler supplies one, the build
|
|
16
|
+
* date; pass-throughs are marked with their antd base so the delegation seam
|
|
17
|
+
* is visible before any per-item call.
|
|
18
|
+
*/
|
|
19
|
+
export function catalogMarkdown(docs, kind, built) {
|
|
20
|
+
const counts = new Map(ITEM_KINDS.map((entry) => [entry, docs.items.filter((item) => item.kind === entry).length]));
|
|
21
|
+
const summary = ITEM_KINDS.map((entry) => plural(counts.get(entry) ?? 0, KIND_LABEL[entry])).join(', ');
|
|
22
|
+
const lines = [`Prism ${docs.prismVersion} — ${summary}${built ? ` (built ${built})` : ''}`, ''];
|
|
23
|
+
if (kind)
|
|
24
|
+
lines.push(`Filtered to ${KIND_LABEL[kind]}s — omit \`kind\` for the whole catalog.`, '');
|
|
25
|
+
for (const entry of ITEM_KINDS) {
|
|
26
|
+
if (kind && entry !== kind)
|
|
27
|
+
continue;
|
|
28
|
+
const inKind = docs.items.filter((item) => item.kind === entry);
|
|
29
|
+
lines.push(`## ${KIND_HEADING[entry]}`, '');
|
|
30
|
+
if (inKind.length === 0) {
|
|
31
|
+
lines.push(`No ${KIND_LABEL[entry]}s in this build.`, '');
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
for (const item of inKind)
|
|
35
|
+
lines.push(catalogEntry(item));
|
|
36
|
+
lines.push('');
|
|
37
|
+
}
|
|
38
|
+
lines.push('---', '', `Next: \`get_item_doc\` for an item's full doc, \`get_item_props\` for its Prism-added props, \`search_docs\` to search everything. Items marked _(extends antd …)_ are pass-throughs — their inherited antd props live in the antd MCP. ${IMPORT_RULE}`);
|
|
39
|
+
return lines.join('\n');
|
|
40
|
+
}
|
|
41
|
+
function catalogEntry(item) {
|
|
42
|
+
const base = item.antdBase ? ` _(extends antd ${item.antdBase})_` : '';
|
|
43
|
+
return `- **${item.name}** — ${item.description}${base}`;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* `get_item_doc` — the generator's page verbatim (usage rules, props, example,
|
|
47
|
+
* the `> Extends:` seam), plus at most one steering footer built from the data.
|
|
48
|
+
*/
|
|
49
|
+
export function itemDocMarkdown(item) {
|
|
50
|
+
const pointers = [];
|
|
51
|
+
if (item.props)
|
|
52
|
+
pointers.push(`Prism-added props only: \`get_item_props { "name": "${item.name}" }\``);
|
|
53
|
+
if ((item.examples?.length ?? 0) > 0)
|
|
54
|
+
pointers.push(`Copyable example source: \`get_item_source { "name": "${item.name}" }\``);
|
|
55
|
+
if (item.antdBase)
|
|
56
|
+
pointers.push(`Inherited antd props and demos: antd MCP \`antd_info ${item.antdBase}\``);
|
|
57
|
+
return pointers.length > 0 ? `${item.doc}\n\n---\n\n${pointers.join(' · ')}` : item.doc;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* `get_item_props` — only the Prism-added delta. A pass-through's answer *is*
|
|
61
|
+
* the routing instruction (ADR-0004 §4: plasma's `_No additional props…_` line
|
|
62
|
+
* is the switch-servers signal).
|
|
63
|
+
*/
|
|
64
|
+
export function itemPropsMarkdown(item) {
|
|
65
|
+
if (item.props) {
|
|
66
|
+
return item.antdBase
|
|
67
|
+
? `${item.props}\n\n---\n\nBeyond these Prism-added props, the inherited antd surface lives in the antd MCP (\`antd_info ${item.antdBase}\`). ${IMPORT_RULE}`
|
|
68
|
+
: item.props;
|
|
69
|
+
}
|
|
70
|
+
if (item.antdBase) {
|
|
71
|
+
return [
|
|
72
|
+
`## ${item.name} — props`,
|
|
73
|
+
'',
|
|
74
|
+
`${item.name} — antd ${item.antdBase}, unchanged. Props: use the antd MCP (\`antd_info ${item.antdBase}\`). ${IMPORT_RULE}`,
|
|
75
|
+
'',
|
|
76
|
+
'_No additional props beyond the antd base component._',
|
|
77
|
+
].join('\n');
|
|
78
|
+
}
|
|
79
|
+
return [
|
|
80
|
+
`## ${item.name} — props`,
|
|
81
|
+
'',
|
|
82
|
+
`\`${item.name}\` documents no Prism-added props in this build. Its usage rules and example live in the full doc: \`get_item_doc { "name": "${item.name}" }\`.`,
|
|
83
|
+
].join('\n');
|
|
84
|
+
}
|
|
85
|
+
/** `get_item_source` — the documented example, verbatim, in one fenced block. */
|
|
86
|
+
export function itemSourceMarkdown(item, example) {
|
|
87
|
+
const labelled = example.title ? `${example.title} (\`${example.slug}\`)` : `\`${example.slug}\``;
|
|
88
|
+
const others = (item.examples ?? []).filter((entry) => entry.slug !== example.slug).map((entry) => `\`${entry.slug}\``);
|
|
89
|
+
const lines = [
|
|
90
|
+
`# ${item.name} — example source: ${labelled}`,
|
|
91
|
+
'',
|
|
92
|
+
'```tsx',
|
|
93
|
+
example.code,
|
|
94
|
+
'```',
|
|
95
|
+
'',
|
|
96
|
+
`Verbatim from the docs demo — self-contained (imports only \`@nanisoft/prism-ui\` and \`react\`). ${IMPORT_RULE}`,
|
|
97
|
+
];
|
|
98
|
+
if (others.length > 0)
|
|
99
|
+
lines.push('', `Other examples: ${others.join(', ')} — pass \`example\` to pick one.`);
|
|
100
|
+
return lines.join('\n');
|
|
101
|
+
}
|
|
102
|
+
/** `get_theme_doc` — the pack × mode atom verbatim, plus the sibling slugs. */
|
|
103
|
+
export function themeMarkdown(theme, all) {
|
|
104
|
+
const others = all.filter((entry) => entry.slug !== theme.slug).map((entry) => `\`${entry.slug}\``);
|
|
105
|
+
const footer = others.length > 0 ? `\n\n---\n\nOther theme atoms: ${others.join(', ')} — pass \`pack\`/\`mode\` to switch.` : '';
|
|
106
|
+
return `${theme.markdown}${footer}`;
|
|
107
|
+
}
|
|
108
|
+
/** `list_pages` — the site's llms.txt body as an index. */
|
|
109
|
+
export function pagesIndexMarkdown(pages, baseUrl) {
|
|
110
|
+
const lines = ['# Prism docs pages', ''];
|
|
111
|
+
if (pages.length === 0) {
|
|
112
|
+
lines.push('This build carries no docs pages — the catalog is the whole corpus for now.');
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
lines.push(`Found ${pages.length}:`, '');
|
|
116
|
+
for (const page of pages) {
|
|
117
|
+
lines.push(`- **${page.title}** — \`${page.url}\`${page.description ? ` — ${page.description}` : ''}`);
|
|
118
|
+
lines.push(` → \`get_page { "url": "${page.url}" }\``);
|
|
119
|
+
}
|
|
120
|
+
lines.push('');
|
|
121
|
+
}
|
|
122
|
+
lines.push('---', '', `Full site index: ${baseUrl}/llms.txt · Catalog: \`list_items\`.`);
|
|
123
|
+
return lines.join('\n');
|
|
124
|
+
}
|
|
125
|
+
/** `get_page` — the prerendered page verbatim, cited back to the site. */
|
|
126
|
+
export function pageMarkdown(page, baseUrl) {
|
|
127
|
+
return `${page.markdown}\n\n---\n\nSource: ${baseUrl}${page.url} · More: \`list_pages\`.`;
|
|
128
|
+
}
|
|
129
|
+
/** `search_docs` — ranked hits, each printing its own next call. */
|
|
130
|
+
export function searchResultsMarkdown(query, hits) {
|
|
131
|
+
const lines = [`# Search results for "${query}"`, ''];
|
|
132
|
+
if (hits.length === 0) {
|
|
133
|
+
lines.push('No matches.', '', 'Try broader terms — or browse: `list_items` for the catalog, `list_pages` for docs pages.');
|
|
134
|
+
return lines.join('\n');
|
|
135
|
+
}
|
|
136
|
+
lines.push(`Found ${hits.length} result(s):`, '');
|
|
137
|
+
hits.forEach((hit, index) => {
|
|
138
|
+
if (index > 0)
|
|
139
|
+
lines.push('---', '');
|
|
140
|
+
lines.push(`## ${hit.title} (${hit.kind})`, hit.snippet, `→ \`${hit.followUp}\`${hit.followUp.startsWith('get_item_source') ? ' for the copyable source.' : ''}`);
|
|
141
|
+
});
|
|
142
|
+
return lines.join('\n');
|
|
143
|
+
}
|
|
144
|
+
/** A lookup miss: the closest names plus the browse pointer, as an error. */
|
|
145
|
+
export function missMarkdown(target, suggestions, browseHint) {
|
|
146
|
+
const lines = [`\`${target}\` not found.`];
|
|
147
|
+
if (suggestions.length > 0)
|
|
148
|
+
lines.push('', `Did you mean: ${suggestions.map((name) => `**${name}**`).join(', ')}?`);
|
|
149
|
+
lines.push('', browseHint);
|
|
150
|
+
return lines.join('\n');
|
|
151
|
+
}
|
|
152
|
+
/** A name hit whose `kind` argument pointed somewhere else. */
|
|
153
|
+
export function kindMismatchMarkdown(item, requested) {
|
|
154
|
+
return `\`${item.name}\` is a ${item.kind}, not a ${requested}. Retry with \`kind\` omitted — or with \`"${item.kind}"\`.`;
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,UAAU,EAAiB,MAAM,aAAa,CAAC;AAGxD,oEAAoE;AACpE,MAAM,CAAC,MAAM,WAAW,GAAG,oEAAoE,CAAC;AAEhG,MAAM,UAAU,GAA6B,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACtG,MAAM,YAAY,GAA6B,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAE3G,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,IAAY,EAAU,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,IAAI,GAAG,CAAC,CAAC;AAE1G;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,IAAoB,EAAE,IAAe,EAAE,KAAc;IACnF,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,MAAM,CAAU,CAAC,CAAC,CAAC;IAC7H,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,CAA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,EAAE,EAAE,CAAC,CAAC;IACpK,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,WAA8B,EAAE,UAAkB;IAC7F,MAAM,KAAK,GAAG,CAAC,KAAK,MAAM,eAAe,CAAC,CAAC;IAC3C,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,iBAAiB,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpH,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;IAC3B,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,oBAAoB,CAAC,IAAmB,EAAE,SAAmB;IAC3E,OAAO,KAAK,IAAI,CAAC,IAAI,WAAW,IAAI,CAAC,IAAI,WAAW,SAAS,8CAA8C,IAAI,CAAC,IAAI,MAAM,CAAC;AAC7H,CAAC"}
|
package/dist/search.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `search_docs` — dependency-free term-frequency ranking over the bundled
|
|
3
|
+
* corpus (ADR-0004 §1: plasma's recipe; the corpus is small enough that no
|
|
4
|
+
* search index earns its bundle size). One entry point over items and docs
|
|
5
|
+
* pages; the component/block/page/doc distinction is a `kind` filter.
|
|
6
|
+
*/
|
|
7
|
+
import type { PrismDocsItem, PrismDocsStore } from './store.js';
|
|
8
|
+
import type { ItemKind } from './lookup.js';
|
|
9
|
+
/** `SearchKind`'s `'doc'` means a docs page, not a `page`-kind catalog item. */
|
|
10
|
+
export type SearchKind = ItemKind | 'doc';
|
|
11
|
+
export interface SearchHit {
|
|
12
|
+
/** The item name or the page title, as the result heading shows it. */
|
|
13
|
+
readonly title: string;
|
|
14
|
+
/** `component | block | page` for catalog items, `doc` for docs pages. */
|
|
15
|
+
readonly kind: SearchKind;
|
|
16
|
+
/** The one-liner the hit is sold with — the same text llms.txt bullets use. */
|
|
17
|
+
readonly snippet: string;
|
|
18
|
+
/** The exact follow-up call the result prints for the agent to make. */
|
|
19
|
+
readonly followUp: string;
|
|
20
|
+
}
|
|
21
|
+
export interface SearchQuery {
|
|
22
|
+
readonly query: string;
|
|
23
|
+
readonly kind?: SearchKind;
|
|
24
|
+
readonly limit?: number;
|
|
25
|
+
}
|
|
26
|
+
/** Default cap — ADR-0004 §7: "search caps at 5 hits with snippets". */
|
|
27
|
+
export declare const DEFAULT_SEARCH_LIMIT = 5;
|
|
28
|
+
export declare const MAX_SEARCH_LIMIT = 10;
|
|
29
|
+
export declare function searchCorpus(docs: PrismDocsStore, { query, kind, limit }: SearchQuery): SearchHit[];
|
|
30
|
+
/** The next call a search hit (or doc footer) prints, steered by the data. */
|
|
31
|
+
export declare function followUpForItem(item: PrismDocsItem): string;
|
|
32
|
+
/** Lower-case word tokens; empty for a whitespace-only query. */
|
|
33
|
+
export declare function tokenize(query: string): string[];
|
|
34
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,gFAAgF;AAChF,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE1C,MAAM,WAAW,SAAS;IACxB,uEAAuE;IACvE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAKD,wEAAwE;AACxE,eAAO,MAAM,oBAAoB,IAAI,CAAC;AACtC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,KAA4B,EAAE,EAAE,WAAW,GAAG,SAAS,EAAE,CA8C1H;AAED,8EAA8E;AAC9E,wBAAgB,eAAe,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAI3D;AAED,iEAAiE;AACjE,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAEhD"}
|
package/dist/search.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `search_docs` — dependency-free term-frequency ranking over the bundled
|
|
3
|
+
* corpus (ADR-0004 §1: plasma's recipe; the corpus is small enough that no
|
|
4
|
+
* search index earns its bundle size). One entry point over items and docs
|
|
5
|
+
* pages; the component/block/page/doc distinction is a `kind` filter.
|
|
6
|
+
*/
|
|
7
|
+
/** Field weights: a name hit outranks a description hit outranks a body hit. */
|
|
8
|
+
const WEIGHTS = { name: 8, summary: 3, body: 1 };
|
|
9
|
+
/** Default cap — ADR-0004 §7: "search caps at 5 hits with snippets". */
|
|
10
|
+
export const DEFAULT_SEARCH_LIMIT = 5;
|
|
11
|
+
export const MAX_SEARCH_LIMIT = 10;
|
|
12
|
+
export function searchCorpus(docs, { query, kind, limit = DEFAULT_SEARCH_LIMIT }) {
|
|
13
|
+
const terms = tokenize(query);
|
|
14
|
+
const capped = Math.min(Math.max(limit, 1), MAX_SEARCH_LIMIT);
|
|
15
|
+
const scoreItem = (item) => terms.reduce((total, term) => total +
|
|
16
|
+
WEIGHTS.name * countOccurrences(item.name.toLowerCase(), term) +
|
|
17
|
+
WEIGHTS.summary * countOccurrences(item.description.toLowerCase(), term) +
|
|
18
|
+
WEIGHTS.body * countOccurrences(item.doc.toLowerCase(), term), 0);
|
|
19
|
+
const scorePage = (page) => terms.reduce((total, term) => total +
|
|
20
|
+
WEIGHTS.name * countOccurrences(page.title.toLowerCase(), term) +
|
|
21
|
+
WEIGHTS.summary * countOccurrences((page.description ?? '').toLowerCase(), term) +
|
|
22
|
+
WEIGHTS.body * countOccurrences(page.markdown.toLowerCase(), term), 0);
|
|
23
|
+
const wantItems = kind === undefined || kind !== 'doc';
|
|
24
|
+
const wantPages = kind === undefined || kind === 'doc';
|
|
25
|
+
const candidates = [];
|
|
26
|
+
if (wantItems) {
|
|
27
|
+
for (const item of docs.items) {
|
|
28
|
+
if (kind !== undefined && item.kind !== kind)
|
|
29
|
+
continue;
|
|
30
|
+
const score = scoreItem(item);
|
|
31
|
+
if (score > 0)
|
|
32
|
+
candidates.push({ score, title: item.name, kind: item.kind, snippet: item.description, followUp: followUpForItem(item) });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (wantPages) {
|
|
36
|
+
for (const page of docs.pages) {
|
|
37
|
+
const score = scorePage(page);
|
|
38
|
+
if (score > 0)
|
|
39
|
+
candidates.push({ score, title: page.title, kind: 'doc', snippet: page.description ?? page.title, followUp: `get_page { "url": "${page.url}" }` });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return candidates
|
|
43
|
+
.sort((a, b) => b.score - a.score || a.title.localeCompare(b.title))
|
|
44
|
+
.slice(0, capped)
|
|
45
|
+
.map(({ score: _score, ...hit }) => hit);
|
|
46
|
+
}
|
|
47
|
+
/** The next call a search hit (or doc footer) prints, steered by the data. */
|
|
48
|
+
export function followUpForItem(item) {
|
|
49
|
+
if ((item.examples?.length ?? 0) > 0)
|
|
50
|
+
return `get_item_source { "name": "${item.name}" }`;
|
|
51
|
+
if (item.antdBase)
|
|
52
|
+
return `antd_info ${item.antdBase} (antd MCP)`;
|
|
53
|
+
return `get_item_doc { "name": "${item.name}" }`;
|
|
54
|
+
}
|
|
55
|
+
/** Lower-case word tokens; empty for a whitespace-only query. */
|
|
56
|
+
export function tokenize(query) {
|
|
57
|
+
return query.toLowerCase().split(/[^a-z0-9]+/).filter((term) => term.length > 0);
|
|
58
|
+
}
|
|
59
|
+
function countOccurrences(haystack, needle) {
|
|
60
|
+
let count = 0;
|
|
61
|
+
let from = haystack.indexOf(needle);
|
|
62
|
+
while (from !== -1) {
|
|
63
|
+
count += 1;
|
|
64
|
+
from = haystack.indexOf(needle, from + needle.length);
|
|
65
|
+
}
|
|
66
|
+
return count;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyBH,gFAAgF;AAChF,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAW,CAAC;AAE1D,wEAAwE;AACxE,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AACtC,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAEnC,MAAM,UAAU,YAAY,CAAC,IAAoB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,GAAG,oBAAoB,EAAe;IAC3G,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CA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,eAAe,CAAC,IAAmB;IACjD,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC;QAAE,OAAO,8BAA8B,IAAI,CAAC,IAAI,KAAK,CAAC;IAC1F,IAAI,IAAI,CAAC,QAAQ;QAAE,OAAO,aAAa,IAAI,CAAC,QAAQ,aAAa,CAAC;IAClE,OAAO,2BAA2B,IAAI,CAAC,IAAI,KAAK,CAAC;AACnD,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,QAAQ,CAAC,KAAa;IACpC,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACnF,CAAC;AAED,SAAS,gBAAgB,CAAC,QAAgB,EAAE,MAAc;IACxD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACpC,OAAO,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC;QACnB,KAAK,IAAI,CAAC,CAAC;QACX,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/store.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The corpus contract (ADR-0004 §5): the single backing store every MCP tool
|
|
3
|
+
* reads. `@nanisoft/prism-llms` emits its projection into this shape at build
|
|
4
|
+
* time (`dist/data.json`) and validates against it type-only; this package is
|
|
5
|
+
* the canonical home because it is the consumer — the tools make exactly one
|
|
6
|
+
* assumption about the corpus, and it is this interface.
|
|
7
|
+
*/
|
|
8
|
+
/** One catalog item — a component, block, or page from prism-ui. */
|
|
9
|
+
export interface PrismDocsItem {
|
|
10
|
+
/** The prism-ui export name, e.g. `Button`, `PageHeader`, `DocsShell`. */
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly kind: 'component' | 'block' | 'page';
|
|
13
|
+
/** The one-liner that becomes the llms.txt bullet and the search hit. */
|
|
14
|
+
readonly description: string;
|
|
15
|
+
/** Full per-item Markdown: usage rules, Prism props, example. */
|
|
16
|
+
readonly doc: string;
|
|
17
|
+
/** The extracted Prism-added props section — absent for pass-throughs. */
|
|
18
|
+
readonly props?: string;
|
|
19
|
+
/** Documented examples; `code` is the verbatim `demos/<slug>.tsx` source. */
|
|
20
|
+
readonly examples?: ReadonlyArray<{
|
|
21
|
+
readonly slug: string;
|
|
22
|
+
readonly title?: string;
|
|
23
|
+
readonly code: string;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* The antd surface this item passes through unchanged (`Button`), absent for
|
|
27
|
+
* wrappers and prism-original items — a wrapper's base rides its doc's
|
|
28
|
+
* `> Extends:` note.
|
|
29
|
+
*/
|
|
30
|
+
readonly antdBase?: string;
|
|
31
|
+
}
|
|
32
|
+
/** One docs page (guides only — blog is lane-only, excluded from the store). */
|
|
33
|
+
export interface PrismDocsPage {
|
|
34
|
+
/** Site pathname, e.g. `/docs/theming`. */
|
|
35
|
+
readonly url: string;
|
|
36
|
+
readonly title: string;
|
|
37
|
+
readonly description?: string;
|
|
38
|
+
readonly markdown: string;
|
|
39
|
+
}
|
|
40
|
+
/** One theme atom per pack × mode (`blue-light`, …), as Markdown. */
|
|
41
|
+
export interface PrismDocsTheme {
|
|
42
|
+
readonly slug: string;
|
|
43
|
+
readonly markdown: string;
|
|
44
|
+
}
|
|
45
|
+
export interface PrismDocsStore {
|
|
46
|
+
/** The resolved prism-ui version — echoed by `list_items` for mismatch detection. */
|
|
47
|
+
readonly prismVersion: string;
|
|
48
|
+
/** `https://prism.nanisoft.com`, interpolated at build. */
|
|
49
|
+
readonly baseUrl: string;
|
|
50
|
+
readonly items: ReadonlyArray<PrismDocsItem>;
|
|
51
|
+
readonly pages: ReadonlyArray<PrismDocsPage>;
|
|
52
|
+
readonly themes: ReadonlyArray<PrismDocsTheme>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Validate an unknown value (typically the parsed `dist/data.json`) against
|
|
56
|
+
* the store contract and return it typed. A JSON import type-widens `kind` to
|
|
57
|
+
* `string`, so only a runtime guard validates the literals — prism-llms'
|
|
58
|
+
* check gate runs this over its emit, and the server factory runs it over its
|
|
59
|
+
* bundled corpus at the door.
|
|
60
|
+
*/
|
|
61
|
+
export declare function parsePrismDocsStore(value: unknown): PrismDocsStore;
|
|
62
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oEAAoE;AACpE,MAAM,WAAW,aAAa;IAC5B,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;IAC9C,yEAAyE;IACzE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,iEAAiE;IACjE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC;QAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;KACvB,CAAC,CAAC;IACH;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,gFAAgF;AAChF,MAAM,WAAW,aAAa;IAC5B,2CAA2C;IAC3C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,qEAAqE;AACrE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,cAAc;IAC7B,qFAAqF;IACrF,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;IAC7C,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;IAC7C,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;CAChD;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAiElE"}
|
package/dist/store.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The corpus contract (ADR-0004 §5): the single backing store every MCP tool
|
|
3
|
+
* reads. `@nanisoft/prism-llms` emits its projection into this shape at build
|
|
4
|
+
* time (`dist/data.json`) and validates against it type-only; this package is
|
|
5
|
+
* the canonical home because it is the consumer — the tools make exactly one
|
|
6
|
+
* assumption about the corpus, and it is this interface.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Validate an unknown value (typically the parsed `dist/data.json`) against
|
|
10
|
+
* the store contract and return it typed. A JSON import type-widens `kind` to
|
|
11
|
+
* `string`, so only a runtime guard validates the literals — prism-llms'
|
|
12
|
+
* check gate runs this over its emit, and the server factory runs it over its
|
|
13
|
+
* bundled corpus at the door.
|
|
14
|
+
*/
|
|
15
|
+
export function parsePrismDocsStore(value) {
|
|
16
|
+
const fail = (path, expected) => {
|
|
17
|
+
throw new TypeError(`PrismDocsStore: ${path} must be ${expected}`);
|
|
18
|
+
};
|
|
19
|
+
const str = (path, v) => (typeof v === 'string' ? v : fail(path, 'a string'));
|
|
20
|
+
const arr = (path, v) => (Array.isArray(v) ? v : fail(path, 'an array'));
|
|
21
|
+
if (typeof value !== 'object' || value === null)
|
|
22
|
+
fail('store', 'an object');
|
|
23
|
+
const store = value;
|
|
24
|
+
const items = arr('items', store.items).map((entry, index) => {
|
|
25
|
+
if (typeof entry !== 'object' || entry === null)
|
|
26
|
+
fail(`items[${index}]`, 'an object');
|
|
27
|
+
const item = entry;
|
|
28
|
+
const rawKind = str(`items[${index}].kind`, item.kind);
|
|
29
|
+
const kind = rawKind === 'component' || rawKind === 'block' || rawKind === 'page' ? rawKind : fail(`items[${index}].kind`, "one of 'component' | 'block' | 'page'");
|
|
30
|
+
const examples = item.examples === undefined
|
|
31
|
+
? undefined
|
|
32
|
+
: arr(`items[${index}].examples`, item.examples).map((example, exampleIndex) => {
|
|
33
|
+
if (typeof example !== 'object' || example === null)
|
|
34
|
+
fail(`items[${index}].examples[${exampleIndex}]`, 'an object');
|
|
35
|
+
const demo = example;
|
|
36
|
+
return {
|
|
37
|
+
slug: str(`items[${index}].examples[${exampleIndex}].slug`, demo.slug),
|
|
38
|
+
...(demo.title !== undefined ? { title: str(`items[${index}].examples[${exampleIndex}].title`, demo.title) } : {}),
|
|
39
|
+
code: str(`items[${index}].examples[${exampleIndex}].code`, demo.code),
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
name: str(`items[${index}].name`, item.name),
|
|
44
|
+
kind,
|
|
45
|
+
description: str(`items[${index}].description`, item.description),
|
|
46
|
+
doc: str(`items[${index}].doc`, item.doc),
|
|
47
|
+
...(item.props !== undefined ? { props: str(`items[${index}].props`, item.props) } : {}),
|
|
48
|
+
...(examples !== undefined ? { examples } : {}),
|
|
49
|
+
...(item.antdBase !== undefined ? { antdBase: str(`items[${index}].antdBase`, item.antdBase) } : {}),
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
const pages = arr('pages', store.pages).map((entry, index) => {
|
|
53
|
+
if (typeof entry !== 'object' || entry === null)
|
|
54
|
+
fail(`pages[${index}]`, 'an object');
|
|
55
|
+
const page = entry;
|
|
56
|
+
return {
|
|
57
|
+
url: str(`pages[${index}].url`, page.url),
|
|
58
|
+
title: str(`pages[${index}].title`, page.title),
|
|
59
|
+
...(page.description !== undefined ? { description: str(`pages[${index}].description`, page.description) } : {}),
|
|
60
|
+
markdown: str(`pages[${index}].markdown`, page.markdown),
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
const themes = arr('themes', store.themes).map((entry, index) => {
|
|
64
|
+
if (typeof entry !== 'object' || entry === null)
|
|
65
|
+
fail(`themes[${index}]`, 'an object');
|
|
66
|
+
const theme = entry;
|
|
67
|
+
return {
|
|
68
|
+
slug: str(`themes[${index}].slug`, theme.slug),
|
|
69
|
+
markdown: str(`themes[${index}].markdown`, theme.markdown),
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
prismVersion: str('prismVersion', store.prismVersion),
|
|
74
|
+
baseUrl: str('baseUrl', store.baseUrl),
|
|
75
|
+
items,
|
|
76
|
+
pages,
|
|
77
|
+
themes,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAoDH;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,QAAgB,EAAS,EAAE;QACrD,MAAM,IAAI,SAAS,CAAC,mBAA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,IAAI,CAAC,UAAU,KAAK,GAAG,EAAE,WAAW,CAAC,CAAC;QACvF,MAAM,KAAK,GAAG,KAAgC,CAAC;QAC/C,OAAO;YACL,IAAI,EAAE,GAAG,CAAC,UAAU,KAAK,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC;YAC9C,QAAQ,EAAE,GAAG,CAAC,UAAU,KAAK,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC;SAC3D,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,YAAY,EAAE,GAAG,CAAC,cAAc,EAAE,KAAK,CAAC,YAAY,CAAC;QACrD,OAAO,EAAE,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC;QACtC,KAAK;QACL,KAAK;QACL,MAAM;KACP,CAAC;AACJ,CAAC"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The eight read-only tools (ADR-0004 §1/§2) — unprefixed names, markdown in
|
|
3
|
+
* and out, `isError: true` for lookup misses (never a throw), tools only (no
|
|
4
|
+
* resources/prompts in v1). Descriptions are the steering surface most clients
|
|
5
|
+
* show, so each carries the scope, the antd delegation rule, and the import
|
|
6
|
+
* invariant.
|
|
7
|
+
*/
|
|
8
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
9
|
+
import { type ItemLookup, type PageLookup, type ThemeLookup } from './lookup.js';
|
|
10
|
+
import type { PrismDocsStore } from './store.js';
|
|
11
|
+
/** Everything a handler reads — built fresh per `createPrismMcpServer()` call. */
|
|
12
|
+
export interface PrismToolContext {
|
|
13
|
+
readonly docs: PrismDocsStore;
|
|
14
|
+
readonly items: ItemLookup;
|
|
15
|
+
readonly pages: PageLookup;
|
|
16
|
+
readonly themes: ThemeLookup;
|
|
17
|
+
/** Corpus build date (YYYY-MM-DD) for the `list_items` header, when known. */
|
|
18
|
+
readonly built?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Registers exactly the eight v1 tools; nothing else (no resources/prompts). */
|
|
21
|
+
export declare function registerPrismTools(server: McpServer, ctx: PrismToolContext): void;
|
|
22
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,8BAA8B,CAAC;AAG9E,OAAO,EAML,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,aAAa,CAAC;AAerB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAYjD,kFAAkF;AAClF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,8EAA8E;IAC9E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAKD,iFAAiF;AACjF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,gBAAgB,GAAG,IAAI,CAmJjF"}
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The eight read-only tools (ADR-0004 §1/§2) — unprefixed names, markdown in
|
|
3
|
+
* and out, `isError: true` for lookup misses (never a throw), tools only (no
|
|
4
|
+
* resources/prompts in v1). Descriptions are the steering surface most clients
|
|
5
|
+
* show, so each carries the scope, the antd delegation rule, and the import
|
|
6
|
+
* invariant.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
import { DEFAULT_MODE, DEFAULT_PACK, resolveExample, themeSlug, } from './lookup.js';
|
|
10
|
+
import { catalogMarkdown, itemDocMarkdown, itemPropsMarkdown, itemSourceMarkdown, kindMismatchMarkdown, missMarkdown, pageMarkdown, pagesIndexMarkdown, searchResultsMarkdown, themeMarkdown, IMPORT_RULE, } from './render.js';
|
|
11
|
+
import { searchCorpus } from './search.js';
|
|
12
|
+
/** Prism-owned surface only; the upstream antd surface delegates. */
|
|
13
|
+
const ANTD_RULE = 'Prism answers its own surface only — inherited antd props, demos, and tokens belong to the antd MCP.';
|
|
14
|
+
const Kind = z.enum(['component', 'block', 'page']);
|
|
15
|
+
const SearchKind = z.enum(['component', 'block', 'page', 'doc']);
|
|
16
|
+
const NAME_DESC = "e.g. 'Button', 'PageHeader', 'SettingsPage'";
|
|
17
|
+
const KIND_DESC = 'Disambiguate when the name exists as more than one kind.';
|
|
18
|
+
const CATALOG_HINT = 'Browse the catalog: `list_items`.';
|
|
19
|
+
/** The one response shape: markdown text, with lookup misses flagged as errors. */
|
|
20
|
+
const markdown = (text, isError = false) => ({ content: [{ type: 'text', text }], isError });
|
|
21
|
+
/** Registers exactly the eight v1 tools; nothing else (no resources/prompts). */
|
|
22
|
+
export function registerPrismTools(server, ctx) {
|
|
23
|
+
server.registerTool('list_items', {
|
|
24
|
+
description: `Catalog of every Prism item — components, blocks, and pages — with kind, one-liner, and antd base. ` +
|
|
25
|
+
`Start here to learn Prism's vocabulary; the header carries the Prism version and the corpus build ` +
|
|
26
|
+
`date, so you can detect a corpus/installed-version mismatch before trusting the answer. ` +
|
|
27
|
+
`${ANTD_RULE} ${IMPORT_RULE}`,
|
|
28
|
+
inputSchema: { kind: Kind.optional().describe('Filter to one kind; omit for the whole catalog.') },
|
|
29
|
+
}, ({ kind }) => markdown(catalogMarkdown(ctx.docs, kind, ctx.built)));
|
|
30
|
+
server.registerTool('get_item_doc', {
|
|
31
|
+
description: `Full Prism documentation for one component, block, or page: usage rules (RFC-2119), Prism-added props, ` +
|
|
32
|
+
`and an example. Covers Prism's own surface only — for inherited antd props on pass-through re-exports ` +
|
|
33
|
+
`use the antd MCP. ${IMPORT_RULE}`,
|
|
34
|
+
inputSchema: { name: z.string().describe(NAME_DESC), kind: Kind.optional().describe(KIND_DESC) },
|
|
35
|
+
}, ({ name, kind }) => {
|
|
36
|
+
const match = ctx.items.find(name, kind);
|
|
37
|
+
if (match.status === 'miss')
|
|
38
|
+
return markdown(missMarkdown(name, match.suggestions, CATALOG_HINT), true);
|
|
39
|
+
if (match.status === 'kind-mismatch')
|
|
40
|
+
return markdown(kindMismatchMarkdown(match.item, kind), true);
|
|
41
|
+
return markdown(itemDocMarkdown(match.item));
|
|
42
|
+
});
|
|
43
|
+
server.registerTool('get_item_props', {
|
|
44
|
+
description: `Prism-added props for one component, block, or page, as Markdown — the API delta Prism adds on top of ` +
|
|
45
|
+
`antd, not the inherited antd table. A pass-through re-export answers with the antd MCP pointer instead. ${IMPORT_RULE}`,
|
|
46
|
+
inputSchema: { name: z.string().describe(NAME_DESC), kind: Kind.optional().describe(KIND_DESC) },
|
|
47
|
+
}, ({ name, kind }) => {
|
|
48
|
+
const match = ctx.items.find(name, kind);
|
|
49
|
+
if (match.status === 'miss')
|
|
50
|
+
return markdown(missMarkdown(name, match.suggestions, CATALOG_HINT), true);
|
|
51
|
+
if (match.status === 'kind-mismatch')
|
|
52
|
+
return markdown(kindMismatchMarkdown(match.item, kind), true);
|
|
53
|
+
return markdown(itemPropsMarkdown(match.item));
|
|
54
|
+
});
|
|
55
|
+
server.registerTool('get_item_source', {
|
|
56
|
+
description: `Documented example source for one item — verbatim, self-contained TSX in one fenced block, ready to paste. ` +
|
|
57
|
+
`Returns documented usage, never prism-ui implementation files; raw antd demos belong to the antd MCP's ` +
|
|
58
|
+
`antd_demo. ${IMPORT_RULE}`,
|
|
59
|
+
inputSchema: {
|
|
60
|
+
name: z.string().describe(NAME_DESC),
|
|
61
|
+
example: z.string().optional().describe("Example slug; omit for the item's first example."),
|
|
62
|
+
},
|
|
63
|
+
}, ({ name, example }) => {
|
|
64
|
+
const match = ctx.items.find(name);
|
|
65
|
+
if (match.status === 'miss')
|
|
66
|
+
return markdown(missMarkdown(name, match.suggestions, CATALOG_HINT), true);
|
|
67
|
+
const item = match.item;
|
|
68
|
+
const resolved = resolveExample(item, example);
|
|
69
|
+
if (resolved.status === 'none') {
|
|
70
|
+
return markdown(`\`${item.name}\` documents no examples in this build — its usage rules live in the full doc: \`get_item_doc { "name": "${item.name}" }\`.`, true);
|
|
71
|
+
}
|
|
72
|
+
if (resolved.status === 'miss') {
|
|
73
|
+
return markdown(missMarkdown(`example "${example}" of ${item.name}`, resolved.suggestions, `Available examples of \`${item.name}\` are listed by its doc: \`get_item_doc { "name": "${item.name}" }\`.`), true);
|
|
74
|
+
}
|
|
75
|
+
return markdown(itemSourceMarkdown(item, resolved.example));
|
|
76
|
+
});
|
|
77
|
+
server.registerTool('get_theme_doc', {
|
|
78
|
+
description: `Theme and token documentation for one Prism brand pack × mode (blue | green × light | dark), including the ` +
|
|
79
|
+
`createPrismTheme() snippet. Prism's multi-pack theming is not answerable by antd's antd_token. ` +
|
|
80
|
+
`${ANTD_RULE} ${IMPORT_RULE}`,
|
|
81
|
+
inputSchema: {
|
|
82
|
+
pack: z.enum(['blue', 'green']).optional().describe(`Brand pack (default '${DEFAULT_PACK}').`),
|
|
83
|
+
mode: z.enum(['light', 'dark']).optional().describe(`Mode (default '${DEFAULT_MODE}').`),
|
|
84
|
+
},
|
|
85
|
+
}, ({ pack, mode }) => {
|
|
86
|
+
const resolvedPack = pack ?? DEFAULT_PACK;
|
|
87
|
+
const resolvedMode = mode ?? DEFAULT_MODE;
|
|
88
|
+
const theme = ctx.themes.find(resolvedPack, resolvedMode);
|
|
89
|
+
if (!theme) {
|
|
90
|
+
const slug = themeSlug(resolvedPack, resolvedMode);
|
|
91
|
+
return markdown(missMarkdown(slug, ctx.themes.suggest(slug), `Available theme atoms: ${ctx.themes.slugs.map((entry) => `\`${entry}\``).join(', ')}.`), true);
|
|
92
|
+
}
|
|
93
|
+
return markdown(themeMarkdown(theme, ctx.docs.themes));
|
|
94
|
+
});
|
|
95
|
+
server.registerTool('list_pages', {
|
|
96
|
+
description: `Index of the Prism docs pages (guides): title, url, and one-liner — the site's llms.txt body. ` +
|
|
97
|
+
`For the component/block/page catalog use list_items. ${IMPORT_RULE}`,
|
|
98
|
+
inputSchema: {},
|
|
99
|
+
}, () => markdown(pagesIndexMarkdown(ctx.docs.pages, ctx.docs.baseUrl)));
|
|
100
|
+
server.registerTool('get_page', {
|
|
101
|
+
description: `One Prism docs page as Markdown, by site pathname (e.g. '/docs/theming') — mirrors fumadocs' get_page ` +
|
|
102
|
+
`contract exactly. Docs describe Prism behaviour; inherited antd surface stays with the antd MCP. ${IMPORT_RULE}`,
|
|
103
|
+
inputSchema: { url: z.string().describe("Site pathname, e.g. '/docs/theming'.") },
|
|
104
|
+
}, ({ url }) => {
|
|
105
|
+
const page = ctx.pages.find(url);
|
|
106
|
+
if (!page)
|
|
107
|
+
return markdown(missMarkdown(url, ctx.pages.suggest(url), 'Index of pages: `list_pages`.'), true);
|
|
108
|
+
return markdown(pageMarkdown(page, ctx.docs.baseUrl));
|
|
109
|
+
});
|
|
110
|
+
server.registerTool('search_docs', {
|
|
111
|
+
description: `One search entry point over the whole Prism corpus — components, blocks, pages, and docs pages. Ranked ` +
|
|
112
|
+
`hits with kind, snippet, and the suggested follow-up call. ${ANTD_RULE} ${IMPORT_RULE}`,
|
|
113
|
+
inputSchema: {
|
|
114
|
+
query: z.string().describe('Free text — item names, features, guide topics.'),
|
|
115
|
+
kind: SearchKind.optional().describe("'doc' means a docs page; the other three filter catalog items."),
|
|
116
|
+
limit: z.number().int().min(1).max(10).optional().describe('Max hits, 1–10 (default 5).'),
|
|
117
|
+
},
|
|
118
|
+
}, ({ query, kind, limit }) => markdown(searchResultsMarkdown(query, searchCorpus(ctx.docs, { query, kind, limit }))));
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","s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,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,+BAA+B,CAAC,EAAE,IAAI,CAAC,CAAC;QAC7G,OAAO,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IACxD,CAAC,CACF,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,aAAa,EACb;QACE,WAAW,EACT,yGAAyG;YACzG,8DAA8D,SAAS,IAAI,WAAW,EAAE;QAC1F,WAAW,EAAE;YACX,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iDAAiD,CAAC;YAC7E,IAAI,EAAE,UAAU,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gEAAgE,CAAC;YACtG,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;SAC1F;KACF,EACD,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC,KAAK,EAAE,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CACnH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MCP server identity (`serverInfo` in the protocol handshake).
|
|
3
|
+
*
|
|
4
|
+
* Keep in sync with `package.json` — this is a literal because importing the
|
|
5
|
+
* package JSON would drag a file outside `rootDir` into the tsc build. This is
|
|
6
|
+
* *protocol* metadata, not the corpus version: `list_items` echoes the store's
|
|
7
|
+
* own `prismVersion` so agents can detect a corpus/installed-version mismatch.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SERVER_NAME = "prism-mcp-server";
|
|
10
|
+
export declare const SERVER_VERSION = "0.1.0";
|
|
11
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,qBAAqB,CAAC;AAC9C,eAAO,MAAM,cAAc,UAAU,CAAC"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MCP server identity (`serverInfo` in the protocol handshake).
|
|
3
|
+
*
|
|
4
|
+
* Keep in sync with `package.json` — this is a literal because importing the
|
|
5
|
+
* package JSON would drag a file outside `rootDir` into the tsc build. This is
|
|
6
|
+
* *protocol* metadata, not the corpus version: `list_items` echoes the store's
|
|
7
|
+
* own `prismVersion` so agents can detect a corpus/installed-version mismatch.
|
|
8
|
+
*/
|
|
9
|
+
export const SERVER_NAME = 'prism-mcp-server';
|
|
10
|
+
export const SERVER_VERSION = '0.1.0';
|
|
11
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC;AAC9C,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nanisoft/prism-mcp-server",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Tool logic for the Prism MCP server — transport-free, fed by prism-llms output. The HTTP transport lives in the apps/site Worker at /mcp.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=22"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@modelcontextprotocol/client": "2.0.0",
|
|
22
|
+
"publint": "^0.3.24",
|
|
23
|
+
"typescript": "^7.0.2",
|
|
24
|
+
"vitest": "^5.0.0"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@modelcontextprotocol/server": "2.0.0",
|
|
28
|
+
"zod": "^4.6.5"
|
|
29
|
+
},
|
|
30
|
+
"author": "NaniSoft",
|
|
31
|
+
"homepage": "https://prism.nanisoft.com",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/NaniSoft/prism.git",
|
|
35
|
+
"directory": "packages/mcp-server"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsc -p tsconfig.json",
|
|
39
|
+
"lint": "oxlint .",
|
|
40
|
+
"test": "vitest run"
|
|
41
|
+
}
|
|
42
|
+
}
|