@adrkit/mcp 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.
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @adrkit/mcp — the one locale-independent comparator and the canonical orderings
3
+ * every channel uses. Never `String.prototype.localeCompare` (research §R6).
4
+ */
5
+ import type { Finding } from '@adrkit/core';
6
+ /** The sole code-unit comparator: `a < b ? -1 : a > b ? 1 : 0` over UTF-16 units. */
7
+ export declare function compareCodeUnits(a: string, b: string): number;
8
+ export interface OrderedSummary {
9
+ readonly id: string;
10
+ readonly sourcePath: string;
11
+ }
12
+ /** Canonical `(id, sourcePath)` ascending order; sourcePath is the unique tiebreak. */
13
+ export declare function compareByIdThenPath(a: OrderedSummary, b: OrderedSummary): number;
14
+ /** Canonical finding order using `sortFindings`' field tuple with the code-unit comparator. */
15
+ export declare function compareFindings(a: Finding, b: Finding): number;
16
+ export declare function sortFindingsCanonical(findings: readonly Finding[]): Finding[];
17
+ export declare function sortByIdThenPath<T extends OrderedSummary>(items: readonly T[]): T[];
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @adrkit/mcp — the per-call, in-memory corpus projection (data-model.md §3, §8).
3
+ *
4
+ * Rebuilt from scratch on every tool call: fresh canonical-root validation, the
5
+ * pre-read 64 KiB size guard, `discoverAdrFiles` + `lintCorpus`, a local multi-valued
6
+ * `byId` index, immutable corpus findings, and a canonical SHA-256 fingerprint.
7
+ * No cache, index, or database of any kind.
8
+ */
9
+ import { type Adr, type Finding } from '@adrkit/core';
10
+ export declare const MAX_SOURCE_BYTES: number;
11
+ export type CorpusUnavailableReason = 'root-not-found' | 'root-not-directory' | 'root-not-readable' | 'root-not-git' | 'dir-not-found' | 'dir-not-directory' | 'dir-not-readable' | 'dir-outside-root' | 'corpus-changed-during-load';
12
+ /** Typed rejection carrying one of the `CorpusUnavailableOutcome` reasons (data-model.md §5). */
13
+ export declare class CorpusUnavailableError extends Error {
14
+ readonly reason: CorpusUnavailableReason;
15
+ constructor(reason: CorpusUnavailableReason);
16
+ }
17
+ export interface CorpusHealth {
18
+ readonly fingerprint: string;
19
+ readonly recordCount: number;
20
+ readonly excludedCount: number;
21
+ }
22
+ export interface CorpusProjection {
23
+ readonly records: readonly Adr[];
24
+ readonly byId: ReadonlyMap<string, readonly Adr[]>;
25
+ readonly corpusFindings: readonly Finding[];
26
+ readonly fingerprint: string;
27
+ readonly recordCount: number;
28
+ readonly excludedCount: number;
29
+ }
30
+ export interface ResolveCanonicalRootsOptions {
31
+ readonly cwd: string;
32
+ readonly dir: string;
33
+ }
34
+ export interface CanonicalRoots {
35
+ readonly canonicalCwd: string;
36
+ readonly canonicalDir: string;
37
+ }
38
+ /** The one canonicalization/containment routine both `start()` and every load call use. */
39
+ export declare function resolveCanonicalRoots(options: ResolveCanonicalRootsOptions): Promise<CanonicalRoots>;
40
+ export interface LoadCorpusProjectionOptions {
41
+ readonly configuredCwd: string;
42
+ readonly configuredDir: string;
43
+ readonly expectedCanonicalCwd: string;
44
+ readonly maxSourceBytes: number;
45
+ }
46
+ /** The one entry point every tool handler calls, fresh, at the start of its execution. */
47
+ export declare function loadCorpusProjection(options: LoadCorpusProjectionOptions): Promise<CorpusProjection>;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @adrkit/mcp — public entry point.
3
+ *
4
+ * Exports ONLY the sealed stdio lifecycle factory and its option/handle types.
5
+ * No SDK server, registration API, internal builder, transport, or test subpath is
6
+ * reachable from here. No side effects at import time; no filesystem access at
7
+ * construction time (data-model.md §8, contracts/tools.md §1).
8
+ */
9
+ export interface AdrkitMcpServerOptions {
10
+ readonly cwd: string;
11
+ readonly dir: string;
12
+ }
13
+ export interface AdrkitMcpServerHandle {
14
+ start(): Promise<void>;
15
+ close(): Promise<void>;
16
+ }
17
+ /**
18
+ * The public stdio lifecycle factory. Performs NO filesystem access at construction;
19
+ * `start()` validates the configured root, builds the closure-private server, creates
20
+ * exactly one `StdioServerTransport`, and connects it. The concrete server, its
21
+ * registrations, and its transport remain unreachable to the caller.
22
+ */
23
+ export declare function createAdrkitMcpServer(options?: Partial<AdrkitMcpServerOptions>): Readonly<AdrkitMcpServerHandle>;