@fenglimg/fabric-server 2.0.1 → 2.2.0-rc.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +332 -160
  2. package/dist/index.js +6463 -5388
  3. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { AgentsMeta, KnowledgeTestIndex, AgentsLayer, AgentsTopologyType, KnowledgeType, Layer, StableId, AgentsMetaCounters, EventLedgerEventInput, EventLedgerEvent, RuleDescriptionIndexItem } from '@fenglimg/fabric-shared';
2
+ import { AgentsMeta, KnowledgeTestIndex, AgentsLayer, AgentsTopologyType, KnowledgeType, Layer, StableId, AgentsMetaCounters, EventLedgerEventInput, EventLedgerEvent, RuleDescriptionIndexItem, LedgerEntry } from '@fenglimg/fabric-shared';
3
3
  import { FabExtractKnowledgeInput, FabExtractKnowledgeOutput, FabReviewInput, FabReviewOutput } from '@fenglimg/fabric-shared/schemas/api-contracts';
4
4
 
5
5
  interface InFlightTracker {
@@ -22,90 +22,79 @@ declare function getLegacyLedgerPath(projectRoot: string): string;
22
22
  declare function getEventLedgerPath(projectRoot: string): string;
23
23
  declare function getMetricsLedgerPath(projectRoot: string): string;
24
24
 
25
- type DoctorStatus = "ok" | "warn" | "error";
26
- type DoctorIssueKind = "fixable_error" | "manual_error" | "warning" | "info";
27
- type DoctorCheck = {
28
- name: string;
29
- status: DoctorStatus;
30
- message: string;
31
- kind?: DoctorIssueKind;
32
- code?: string;
33
- fixable?: boolean;
34
- actionHint?: string;
35
- audience?: "user" | "maintainer";
36
- };
37
- type DoctorIssue = {
38
- code: string;
39
- name: string;
40
- message: string;
41
- path?: string;
42
- actionHint?: string;
43
- audience?: "user" | "maintainer";
44
- };
45
- type DoctorPayloadLimits = {
46
- warn_bytes: number;
47
- hard_bytes: number;
48
- source: "default" | "config";
49
- };
50
- type DoctorSummary = {
51
- target: string;
52
- framework: {
53
- kind: string;
54
- version: string;
55
- subkind: string;
56
- };
57
- entryPoints: Array<{
58
- path: string;
59
- reason: string;
60
- }>;
61
- metaRevision: string | null;
62
- computedMetaRevision: string | null;
63
- ruleCount: number;
64
- eventLedgerPath: string;
65
- fixableErrorCount: number;
66
- manualErrorCount: number;
67
- warningCount: number;
68
- infoCount: number;
69
- targetFiles: Record<string, boolean>;
70
- payload_limits: DoctorPayloadLimits;
71
- };
72
- type DoctorReport = {
73
- status: DoctorStatus;
74
- checks: DoctorCheck[];
75
- fixable_errors: DoctorIssue[];
76
- manual_errors: DoctorIssue[];
77
- warnings: DoctorIssue[];
78
- infos: DoctorIssue[];
79
- summary: DoctorSummary;
80
- };
81
- type DoctorFixReport = {
82
- changed: boolean;
83
- fixed: DoctorIssue[];
84
- remaining_manual_errors: DoctorIssue[];
85
- warnings: DoctorIssue[];
86
- message: string;
87
- report: DoctorReport;
88
- };
89
- type DoctorApplyLintMutationKind = "knowledge_orphan_demote_required" | "knowledge_stale_archive_required" | "knowledge_index_drift" | "knowledge_pending_auto_archive" | "knowledge_session_hints_stale_cleanup" | "knowledge_relevance_fields_missing";
90
- type DoctorApplyLintMutation = {
91
- kind: DoctorApplyLintMutationKind;
92
- path: string;
93
- detail: string;
94
- applied: boolean;
95
- error?: string;
25
+ /**
26
+ * O(1) in-memory increment for a named counter. Safe to call from any MCP
27
+ * tool handler; no I/O happens until the next `flushMetrics()` call.
28
+ *
29
+ * `delta` defaults to 1; callers can pass a positive integer (e.g. fetched
30
+ * N stable_ids in a single sections call) to fold N bumps into one.
31
+ */
32
+ declare function bumpCounter(projectRoot: string, name: string, delta?: number): void;
33
+ /**
34
+ * Snapshot the current counter accumulator and reset it. Returned map is a
35
+ * frozen copy; the live accumulator starts fresh from zero. Exposed so
36
+ * flushMetrics + tests + a future fab_metrics manual-flush CLI hook can all
37
+ * use the same primitive without racing.
38
+ */
39
+ declare function drainCounters(projectRoot: string): Record<string, number>;
40
+ /**
41
+ * Drain the current accumulator and append one JSONL row to
42
+ * `.fabric/metrics.jsonl`. Returns the appended row (or `null` when the
43
+ * accumulator was empty — no spurious zero rows). fs failures degrade
44
+ * silently; the next flush will carry the union of the failed-write
45
+ * interval + the current one.
46
+ */
47
+ declare function flushMetrics(projectRoot: string, options?: {
48
+ windowMs?: number;
49
+ now?: Date;
50
+ }): Promise<MetricsRow | null>;
51
+ /**
52
+ * Start the background flush timer for a project root. Idempotent — calling
53
+ * twice on the same root replaces the prior interval. Returns a stop handle
54
+ * the caller can invoke at shutdown to flush + clear the timer.
55
+ *
56
+ * The flush is fire-and-forget (no await on the setInterval callback) so
57
+ * the timer cadence stays accurate even when fs is slow.
58
+ */
59
+ declare function startMetricsFlush(projectRoot: string, options?: {
60
+ intervalMs?: number;
61
+ }): () => Promise<void>;
62
+ /**
63
+ * Cancel the background flush timer for a project root if one is running.
64
+ * Does NOT drain the accumulator — callers that want a final flush should
65
+ * await flushMetrics(projectRoot) afterward.
66
+ */
67
+ declare function stopMetricsFlush(projectRoot: string): void;
68
+ /**
69
+ * Read accumulated metrics rows from `.fabric/metrics.jsonl`. Missing file
70
+ * returns []. Malformed rows are dropped silently (the sidecar is best-
71
+ * effort observability; a corrupt row never blocks a reader).
72
+ *
73
+ * Exposed for the NEW-34 `fab metrics` CLI dashboard + future doctor lints
74
+ * (e.g. cite-goodhart pattern replay) that need counter trends without
75
+ * walking events.jsonl.
76
+ */
77
+ declare function readMetrics(projectRoot: string): Promise<MetricsRow[]>;
78
+ type MetricsRow = {
79
+ timestamp: string;
80
+ window: string;
81
+ counters: Record<string, number>;
96
82
  };
97
- type DoctorApplyLintReport = {
98
- changed: boolean;
99
- mutations: DoctorApplyLintMutation[];
100
- manual_errors: DoctorIssue[];
101
- aborted: boolean;
102
- abort_reason?: string;
103
- message: string;
104
- report: DoctorReport;
83
+ /**
84
+ * Canonical metric counter names used by the high-frequency emitters that
85
+ * left events.jsonl as part of the rc.37 Wave B clean-slate. Centralized
86
+ * here so the B5 hard-gate (`metric_event_in_jsonl`) can grep for these
87
+ * exact strings and fail when one accidentally re-appears in the audit
88
+ * ledger emit path.
89
+ */
90
+ declare const METRIC_COUNTER_NAMES: {
91
+ readonly knowledge_consumed: "knowledge_consumed";
92
+ readonly edit_intent_checked: "edit_intent_checked";
93
+ readonly knowledge_context_planned: "knowledge_context_planned";
94
+ readonly knowledge_sections_fetched: "knowledge_sections_fetched";
105
95
  };
106
- declare function runDoctorReport(target: string): Promise<DoctorReport>;
107
- declare function runDoctorFix(target: string): Promise<DoctorFixReport>;
108
- declare function runDoctorApplyLint(target: string): Promise<DoctorApplyLintReport>;
96
+ type MetricCounterName = (typeof METRIC_COUNTER_NAMES)[keyof typeof METRIC_COUNTER_NAMES];
97
+
109
98
  type CiteContractMetrics = {
110
99
  decisions_cited: number;
111
100
  pitfalls_cited: number;
@@ -192,6 +181,101 @@ type HistoryAllReport = {
192
181
  declare function runDoctorHistoryAll(projectRoot: string, options: {
193
182
  since: number;
194
183
  }): Promise<HistoryAllReport>;
184
+
185
+ type DoctorStatus = "ok" | "warn" | "error";
186
+ type DoctorIssueKind = "fixable_error" | "manual_error" | "warning" | "info";
187
+ type DoctorCheck = {
188
+ name: string;
189
+ status: DoctorStatus;
190
+ message: string;
191
+ kind?: DoctorIssueKind;
192
+ code?: string;
193
+ fixable?: boolean;
194
+ actionHint?: string;
195
+ audience?: "user" | "maintainer";
196
+ };
197
+ type DoctorIssue = {
198
+ code: string;
199
+ name: string;
200
+ message: string;
201
+ path?: string;
202
+ actionHint?: string;
203
+ audience?: "user" | "maintainer";
204
+ };
205
+ type DoctorPayloadLimits = {
206
+ warn_bytes: number;
207
+ hard_bytes: number;
208
+ source: "default" | "config";
209
+ };
210
+ type DoctorSummary = {
211
+ target: string;
212
+ framework: {
213
+ kind: string;
214
+ version: string;
215
+ subkind: string;
216
+ };
217
+ entryPoints: Array<{
218
+ path: string;
219
+ reason: string;
220
+ }>;
221
+ metaRevision: string | null;
222
+ computedMetaRevision: string | null;
223
+ ruleCount: number;
224
+ eventLedgerPath: string;
225
+ fixableErrorCount: number;
226
+ manualErrorCount: number;
227
+ warningCount: number;
228
+ infoCount: number;
229
+ targetFiles: Record<string, boolean>;
230
+ payload_limits: DoctorPayloadLimits;
231
+ health: DoctorHealth;
232
+ };
233
+ type DoctorHealth = {
234
+ score: number;
235
+ grade: "A" | "B" | "C" | "D" | "F";
236
+ penalties: {
237
+ manual_errors: number;
238
+ fixable_errors: number;
239
+ warnings: number;
240
+ };
241
+ };
242
+ type DoctorReport = {
243
+ status: DoctorStatus;
244
+ checks: DoctorCheck[];
245
+ fixable_errors: DoctorIssue[];
246
+ manual_errors: DoctorIssue[];
247
+ warnings: DoctorIssue[];
248
+ infos: DoctorIssue[];
249
+ summary: DoctorSummary;
250
+ };
251
+ type DoctorFixReport = {
252
+ changed: boolean;
253
+ fixed: DoctorIssue[];
254
+ remaining_manual_errors: DoctorIssue[];
255
+ warnings: DoctorIssue[];
256
+ message: string;
257
+ report: DoctorReport;
258
+ };
259
+ type DoctorApplyLintMutationKind = "knowledge_orphan_demote_required" | "knowledge_stale_archive_required" | "knowledge_index_drift" | "knowledge_pending_auto_archive" | "knowledge_session_hints_stale_cleanup" | "knowledge_relevance_fields_missing";
260
+ type DoctorApplyLintMutation = {
261
+ kind: DoctorApplyLintMutationKind;
262
+ path: string;
263
+ detail: string;
264
+ applied: boolean;
265
+ error?: string;
266
+ };
267
+ type DoctorApplyLintReport = {
268
+ changed: boolean;
269
+ mutations: DoctorApplyLintMutation[];
270
+ manual_errors: DoctorIssue[];
271
+ aborted: boolean;
272
+ abort_reason?: string;
273
+ message: string;
274
+ report: DoctorReport;
275
+ };
276
+ declare function runDoctorReport(target: string): Promise<DoctorReport>;
277
+ declare function runDoctorFix(target: string): Promise<DoctorFixReport>;
278
+ declare function runDoctorApplyLint(target: string): Promise<DoctorApplyLintReport>;
195
279
  type EnrichDescriptionsMode = "auto" | "preview" | "readonly" | "interactive";
196
280
  type EnrichDescriptionsCandidate = {
197
281
  path: string;
@@ -329,7 +413,34 @@ declare function extractKnowledge(projectRoot: string, input: FabExtractKnowledg
329
413
  declare function reviewKnowledge(projectRoot: string, input: FabReviewInput): Promise<FabReviewOutput>;
330
414
 
331
415
  type StoredEventLedgerEvent = EventLedgerEvent;
416
+ type ReadEventLedgerOptions = {
417
+ event_type?: EventLedgerEvent["event_type"];
418
+ since?: number;
419
+ correlation_id?: string;
420
+ session_id?: string;
421
+ };
422
+ type LedgerWarning = {
423
+ kind: "partial_write_at_tail";
424
+ byte_offset: number;
425
+ byte_length: number;
426
+ snippet_first_120: string;
427
+ } | {
428
+ kind: "schema_version_unsupported";
429
+ line_index: number;
430
+ schema_version: unknown;
431
+ snippet_first_120: string;
432
+ } | {
433
+ kind: "event_type_unknown";
434
+ line_index: number;
435
+ event_type: unknown;
436
+ snippet_first_120: string;
437
+ };
438
+ type ReadEventLedgerResult = {
439
+ events: StoredEventLedgerEvent[];
440
+ warnings: LedgerWarning[];
441
+ };
332
442
  declare function appendEventLedgerEvent(projectRoot: string, event: EventLedgerEventInput): Promise<StoredEventLedgerEvent>;
443
+ declare function readEventLedger(projectRoot: string, options?: ReadEventLedgerOptions): Promise<ReadEventLedgerResult>;
333
444
  /**
334
445
  * Synchronously fsync the event ledger file to ensure OS page-cache buffers are
335
446
  * flushed to durable storage. Must be called AFTER in-flight drain but BEFORE
@@ -373,6 +484,7 @@ type PlanContextResult = {
373
484
  selection_token: string;
374
485
  entries: PlanContextEntry[];
375
486
  candidates: RuleDescriptionIndexItem[];
487
+ omitted_candidate_count?: number;
376
488
  preflight_diagnostics: PreflightDiagnostic[];
377
489
  auto_healed?: boolean;
378
490
  previous_revision_hash?: string;
@@ -398,6 +510,18 @@ type RecallInput = PlanContextInput & {
398
510
  * provided, filters the fetched body set to this intersection.
399
511
  */
400
512
  ids?: string[];
513
+ /**
514
+ * v2.2 MC1-recall-pack (W2-T4): when true, expand the fetched set with the
515
+ * one-hop `related` graph neighbours (H2) of the selected entries that are
516
+ * also present in the candidate index. Lets a scoped `ids` recall pull in the
517
+ * connected knowledge without a second round-trip. No-op when `ids` is omitted
518
+ * (every candidate is already fetched) or no related edges resolve in-corpus.
519
+ */
520
+ include_related?: boolean;
521
+ };
522
+ type RecallTruncation = {
523
+ omitted_candidate_count: number;
524
+ returned_candidate_count: number;
401
525
  };
402
526
  type RecallResult = PlanContextResult & {
403
527
  rules: Array<{
@@ -413,82 +537,12 @@ type RecallResult = PlanContextResult & {
413
537
  stable_id: string;
414
538
  message: string;
415
539
  }>;
540
+ directive: string;
541
+ next_steps?: string[];
542
+ truncation?: RecallTruncation;
416
543
  };
417
544
  declare function recall(projectRoot: string, input: RecallInput): Promise<RecallResult>;
418
545
 
419
- /**
420
- * O(1) in-memory increment for a named counter. Safe to call from any MCP
421
- * tool handler; no I/O happens until the next `flushMetrics()` call.
422
- *
423
- * `delta` defaults to 1; callers can pass a positive integer (e.g. fetched
424
- * N stable_ids in a single sections call) to fold N bumps into one.
425
- */
426
- declare function bumpCounter(projectRoot: string, name: string, delta?: number): void;
427
- /**
428
- * Snapshot the current counter accumulator and reset it. Returned map is a
429
- * frozen copy; the live accumulator starts fresh from zero. Exposed so
430
- * flushMetrics + tests + a future fab_metrics manual-flush CLI hook can all
431
- * use the same primitive without racing.
432
- */
433
- declare function drainCounters(projectRoot: string): Record<string, number>;
434
- /**
435
- * Drain the current accumulator and append one JSONL row to
436
- * `.fabric/metrics.jsonl`. Returns the appended row (or `null` when the
437
- * accumulator was empty — no spurious zero rows). fs failures degrade
438
- * silently; the next flush will carry the union of the failed-write
439
- * interval + the current one.
440
- */
441
- declare function flushMetrics(projectRoot: string, options?: {
442
- windowMs?: number;
443
- now?: Date;
444
- }): Promise<MetricsRow | null>;
445
- /**
446
- * Start the background flush timer for a project root. Idempotent — calling
447
- * twice on the same root replaces the prior interval. Returns a stop handle
448
- * the caller can invoke at shutdown to flush + clear the timer.
449
- *
450
- * The flush is fire-and-forget (no await on the setInterval callback) so
451
- * the timer cadence stays accurate even when fs is slow.
452
- */
453
- declare function startMetricsFlush(projectRoot: string, options?: {
454
- intervalMs?: number;
455
- }): () => Promise<void>;
456
- /**
457
- * Cancel the background flush timer for a project root if one is running.
458
- * Does NOT drain the accumulator — callers that want a final flush should
459
- * await flushMetrics(projectRoot) afterward.
460
- */
461
- declare function stopMetricsFlush(projectRoot: string): void;
462
- /**
463
- * Read accumulated metrics rows from `.fabric/metrics.jsonl`. Missing file
464
- * returns []. Malformed rows are dropped silently (the sidecar is best-
465
- * effort observability; a corrupt row never blocks a reader).
466
- *
467
- * Exposed for the NEW-34 `fab metrics` CLI dashboard + future doctor lints
468
- * (e.g. cite-goodhart pattern replay) that need counter trends without
469
- * walking events.jsonl.
470
- */
471
- declare function readMetrics(projectRoot: string): Promise<MetricsRow[]>;
472
- type MetricsRow = {
473
- timestamp: string;
474
- window: string;
475
- counters: Record<string, number>;
476
- };
477
- /**
478
- * Canonical metric counter names used by the high-frequency emitters that
479
- * left events.jsonl as part of the rc.37 Wave B clean-slate. Centralized
480
- * here so the B5 hard-gate (`metric_event_in_jsonl`) can grep for these
481
- * exact strings and fail when one accidentally re-appears in the audit
482
- * ledger emit path.
483
- */
484
- declare const METRIC_COUNTER_NAMES: {
485
- readonly knowledge_consumed: "knowledge_consumed";
486
- readonly edit_intent_checked: "edit_intent_checked";
487
- readonly knowledge_context_planned: "knowledge_context_planned";
488
- readonly knowledge_sections_fetched: "knowledge_sections_fetched";
489
- };
490
- type MetricCounterName = (typeof METRIC_COUNTER_NAMES)[keyof typeof METRIC_COUNTER_NAMES];
491
-
492
546
  /**
493
547
  * Start the background rotation timer for a project root. Idempotent —
494
548
  * calling twice on the same root replaces the prior interval. Returns a
@@ -511,10 +565,47 @@ declare function startRotationTick(projectRoot: string, options?: {
511
565
  declare function stopRotationTick(projectRoot: string): void;
512
566
 
513
567
  /**
514
- * Shared constants used across the server package.
568
+ * ContextCache unified hot-path cache for the Fabric server.
569
+ *
570
+ * Three logical slots:
571
+ * 1. "meta" — agents.meta.json content (TTL-based, default 5 s)
572
+ * 2. "context" — GetKnowledgeContext per projectRoot (TTL-based, default 5 s)
573
+ * 3. "audit" — sliding-window byte-offset cursor for audit.jsonl reads
574
+ *
575
+ * Invalidation reasons:
576
+ * - "meta_write" — eager invalidation when a write service mutates agents.meta.json
577
+ * - "file_watch" — chokidar detected an on-disk change
515
578
  */
516
- /** MCP resource URI for the project's bootstrap README (L0 rules) file. */
517
- declare const AGENTS_MD_RESOURCE_URI = "fabric://bootstrap-readme";
579
+ type InvalidationReason = "meta_write" | "file_watch";
580
+ type AuditCursor = {
581
+ offset: number;
582
+ remainder: string;
583
+ windowEntries: Array<{
584
+ ts: number;
585
+ }>;
586
+ };
587
+ declare class ContextCache {
588
+ private readonly defaultTtlMs;
589
+ private readonly metaSlot;
590
+ private readonly contextSlot;
591
+ private readonly auditSlot;
592
+ constructor(defaultTtlMs?: number);
593
+ get<T>(slot: "meta" | "context", key: string): T | undefined;
594
+ set<T>(slot: "meta" | "context", key: string, value: T, ttlMs?: number): void;
595
+ getAuditCursor(projectRoot: string): AuditCursor | undefined;
596
+ setAuditCursor(projectRoot: string, cursor: AuditCursor): void;
597
+ resetAuditCursor(projectRoot: string): void;
598
+ /**
599
+ * Invalidate cache slots based on what changed.
600
+ *
601
+ * @param reason "meta_write" — only the meta slot for this projectRoot
602
+ * "file_watch" — meta + context slots (AGENTS.md may have changed)
603
+ * @param projectRoot Optional; if omitted, clears ALL keys in affected slots.
604
+ */
605
+ invalidate(reason: InvalidationReason, projectRoot?: string): void;
606
+ private slotStore;
607
+ }
608
+ declare const contextCache: ContextCache;
518
609
 
519
610
  interface KnowledgeSyncOptions {
520
611
  mode?: "incremental" | "full";
@@ -563,6 +654,12 @@ interface KnowledgeSyncReport {
563
654
  warnings: StructuredWarning[];
564
655
  reconciled_files?: string[];
565
656
  }
657
+ /**
658
+ * Clear the knowledge-sync cooldown for a projectRoot so the next ensureKnowledgeFresh
659
+ * call performs a real I/O scan. Called by the chokidar watcher when a rule
660
+ * file changes (see http.ts handleCacheWatcherEvent).
661
+ */
662
+ declare function invalidateKnowledgeSyncCooldown(projectRoot: string): void;
566
663
  /**
567
664
  * Detects drift between disk and agents.meta.json, emits ledger events, and
568
665
  * invalidates the cache. Does NOT rewrite agents.meta.json. Optimised for
@@ -596,6 +693,80 @@ interface ReconcileKnowledgeOptions {
596
693
  */
597
694
  declare function reconcileKnowledge(projectRoot: string, opts?: ReconcileKnowledgeOptions): Promise<KnowledgeSyncReport>;
598
695
 
696
+ type LedgerSourceFilter = "ai" | "human";
697
+ type StoredLedgerEntry = LedgerEntry & {
698
+ id: string;
699
+ };
700
+ type ReadLedgerOptions = {
701
+ source?: LedgerSourceFilter;
702
+ since?: number;
703
+ };
704
+ type ResolvedLedgerPaths = {
705
+ primaryPath: string;
706
+ legacyPath: string;
707
+ readPath: string;
708
+ usingLegacy: boolean;
709
+ };
710
+ declare function resolveLedgerPaths(projectRoot: string): Promise<ResolvedLedgerPaths>;
711
+ declare function readLedger(projectRoot: string, options?: ReadLedgerOptions): Promise<StoredLedgerEntry[]>;
712
+
713
+ type RehydrateTarget = {
714
+ ledgerEntryId: string;
715
+ } | {
716
+ timestamp: number;
717
+ };
718
+ type RehydratedAgentsMetaSnapshot = {
719
+ meta: AgentsMeta;
720
+ metadata: {
721
+ at_ledger_id: string;
722
+ at_commit: string | null;
723
+ replayed_count: number;
724
+ mode: "git-show" | "ledger-fallback";
725
+ };
726
+ entries: StoredLedgerEntry[];
727
+ };
728
+ declare function rehydrateAgentsMetaAt(projectRoot: string, target: RehydrateTarget): Promise<RehydratedAgentsMetaSnapshot>;
729
+
730
+ declare function readAgentsMeta(projectRoot: string): Promise<AgentsMeta>;
731
+
732
+ type KnowledgeEntryItem = {
733
+ path: string;
734
+ content: string;
735
+ };
736
+ type DescriptionStub = {
737
+ path: string;
738
+ description: string;
739
+ };
740
+ type HumanLockedNearby = {
741
+ file: string;
742
+ excerpt: string;
743
+ };
744
+ type KnowledgePayload = {
745
+ L0: string;
746
+ L1: KnowledgeEntryItem[];
747
+ L2: KnowledgeEntryItem[];
748
+ human_locked_nearby: HumanLockedNearby[];
749
+ description_stubs?: DescriptionStub[];
750
+ };
751
+ type GetKnowledgeInput = {
752
+ path: string;
753
+ client_hash?: string;
754
+ correlation_id?: string;
755
+ session_id?: string;
756
+ };
757
+ type GetKnowledgeResult = {
758
+ revision_hash: string;
759
+ stale: boolean;
760
+ rules: KnowledgePayload;
761
+ };
762
+ declare function getKnowledge(projectRoot: string, input: GetKnowledgeInput): Promise<GetKnowledgeResult>;
763
+
764
+ /**
765
+ * Shared constants used across the server package.
766
+ */
767
+ /** MCP resource URI for the project's bootstrap README (L0 rules) file. */
768
+ declare const AGENTS_MD_RESOURCE_URI = "fabric://bootstrap-readme";
769
+
599
770
  /**
600
771
  * Returns an info-level startup message when CLAUDE.md or AGENTS.md exist at
601
772
  * the project root, or null when neither is present.
@@ -605,6 +776,7 @@ declare function reconcileKnowledge(projectRoot: string, opts?: ReconcileKnowled
605
776
  */
606
777
  declare function formatPreexistingRootMessage(projectRoot: string): string | null;
607
778
 
779
+ declare const FABRIC_SERVER_INSTRUCTIONS: string;
608
780
  declare function createFabricServer(tracker?: InFlightTracker): McpServer;
609
781
  declare function startStdioServer(): Promise<void>;
610
782
  /**
@@ -631,4 +803,4 @@ interface ShutdownHandlerDeps {
631
803
  */
632
804
  declare function createShutdownHandler(deps: ShutdownHandlerDeps): () => void;
633
805
 
634
- export { AGENTS_MD_RESOURCE_URI, type ArchiveHistoryEntry, type ArchiveHistoryReport, type CiteCoverageReport, type DoctorApplyLintMutation, type DoctorApplyLintMutationKind, type DoctorApplyLintReport, type DoctorFixReport, type DoctorIssue, type DoctorReport, EVENT_LEDGER_PATH, type EnrichDescriptionsCandidate, type EnrichDescriptionsMode, type EnrichDescriptionsReport, type HistoryAllReport, type HistoryDayRow, type InFlightTracker, KnowledgeIdAllocator, type KnowledgeMetaBuildResult, type KnowledgeMetaBuildSource, type KnowledgeSyncLedgerEvent, type KnowledgeSyncOptions, type KnowledgeSyncReport, LEDGER_PATH, LEGACY_LEDGER_PATH, type LedgerEvent, METRICS_LEDGER_PATH, METRIC_COUNTER_NAMES, type MetricCounterName, type MetricsRow, type PlanContextInput, type PlanContextResult, type RecallInput, type RecallResult, type ReconcileKnowledgeOptions, type RequirementProfile, type SelectionTokenState, type ShutdownHandlerDeps, type StructuredWarning, type WriteKnowledgeMetaOptions, appendEventLedgerEvent, buildKnowledgeMeta, bumpCounter, computeKnowledgeBasedAgentsMeta, computeKnowledgeTestIndex, createFabricServer, createInFlightTracker, createShutdownHandler, deriveKnowledgeMetaLayer, deriveKnowledgeMetaTopologyType, drainCounters, enrichDescriptions, ensureKnowledgeFresh, extractKnowledge, flushAndSyncEventLedger, flushMetrics, formatPreexistingRootMessage, getEventLedgerPath, getLedgerPath, getLegacyLedgerPath, getMetricsLedgerPath, isSameKnowledgeTestIndex, loadKbIdTypeMap, planContext, readMetrics, readSelectionToken, recall, reconcileKnowledge, reviewKnowledge, runDoctorApplyLint, runDoctorArchiveHistory, runDoctorCiteCoverage, runDoctorFix, runDoctorHistoryAll, runDoctorReport, stableStringify, startMetricsFlush, startRotationTick, startStdioServer, stopMetricsFlush, stopRotationTick, writeKnowledgeMeta };
806
+ export { AGENTS_MD_RESOURCE_URI, type ArchiveHistoryEntry, type ArchiveHistoryReport, type CiteCoverageReport, type DoctorApplyLintMutation, type DoctorApplyLintMutationKind, type DoctorApplyLintReport, type DoctorFixReport, type DoctorIssue, type DoctorReport, EVENT_LEDGER_PATH, type EnrichDescriptionsCandidate, type EnrichDescriptionsMode, type EnrichDescriptionsReport, FABRIC_SERVER_INSTRUCTIONS, type HistoryAllReport, type HistoryDayRow, type InFlightTracker, KnowledgeIdAllocator, type KnowledgeMetaBuildResult, type KnowledgeMetaBuildSource, type KnowledgeSyncLedgerEvent, type KnowledgeSyncOptions, type KnowledgeSyncReport, LEDGER_PATH, LEGACY_LEDGER_PATH, type LedgerEvent, METRICS_LEDGER_PATH, METRIC_COUNTER_NAMES, type MetricCounterName, type MetricsRow, type PlanContextInput, type PlanContextResult, type RecallInput, type RecallResult, type ReconcileKnowledgeOptions, type RequirementProfile, type SelectionTokenState, type ShutdownHandlerDeps, type StructuredWarning, type WriteKnowledgeMetaOptions, appendEventLedgerEvent, buildKnowledgeMeta, bumpCounter, computeKnowledgeBasedAgentsMeta, computeKnowledgeTestIndex, contextCache, createFabricServer, createInFlightTracker, createShutdownHandler, deriveKnowledgeMetaLayer, deriveKnowledgeMetaTopologyType, drainCounters, enrichDescriptions, ensureKnowledgeFresh, extractKnowledge, flushAndSyncEventLedger, flushMetrics, formatPreexistingRootMessage, getEventLedgerPath, getKnowledge, getLedgerPath, getLegacyLedgerPath, getMetricsLedgerPath, invalidateKnowledgeSyncCooldown, isSameKnowledgeTestIndex, loadKbIdTypeMap, planContext, readAgentsMeta, readEventLedger, readLedger, readMetrics, readSelectionToken, recall, reconcileKnowledge, rehydrateAgentsMetaAt, resolveLedgerPaths, reviewKnowledge, runDoctorApplyLint, runDoctorArchiveHistory, runDoctorCiteCoverage, runDoctorFix, runDoctorHistoryAll, runDoctorReport, stableStringify, startMetricsFlush, startRotationTick, startStdioServer, stopMetricsFlush, stopRotationTick, writeKnowledgeMeta };