@fenglimg/fabric-server 2.2.0-rc.3 → 2.2.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +17 -155
- package/dist/index.js +1498 -2903
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { AgentsMeta, KnowledgeTestIndex, AgentsLayer, AgentsTopologyType, KnowledgeType, Layer, StableId, AgentsMetaCounters, EventLedgerEventInput, EventLedgerEvent, RuleDescriptionIndexItem, LedgerEntry } from '@fenglimg/fabric-shared';
|
|
3
2
|
import { FabExtractKnowledgeInput, FabExtractKnowledgeOutput, FabReviewInput, FabReviewOutput } from '@fenglimg/fabric-shared/schemas/api-contracts';
|
|
3
|
+
import { EventLedgerEventInput, EventLedgerEvent, RuleDescriptionIndexItem, LedgerEntry, AgentsMeta } from '@fenglimg/fabric-shared';
|
|
4
4
|
|
|
5
5
|
interface InFlightTracker {
|
|
6
6
|
enter(requestId: string): void;
|
|
@@ -421,10 +421,12 @@ interface ConflictLintReport {
|
|
|
421
421
|
pairs: ConflictPair[];
|
|
422
422
|
}
|
|
423
423
|
/**
|
|
424
|
-
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
*
|
|
424
|
+
* v2.2 W5 R6 (读侧 cutover): load canonical knowledge entries with bodies from
|
|
425
|
+
* the read-set STORES (cross-store on-the-fly) instead of the retired
|
|
426
|
+
* co-location agents.meta node index. Skips pending/draft staging entries
|
|
427
|
+
* (conflict detection targets the curated corpus) and any entry missing a
|
|
428
|
+
* knowledge_type. collectStoreCanonicalEntries already reads each store entry's
|
|
429
|
+
* body + parsed frontmatter and degrades to [] when no store is in the read-set.
|
|
428
430
|
*/
|
|
429
431
|
declare function loadConflictEntries(projectRoot: string): Promise<ConflictEntry[]>;
|
|
430
432
|
/**
|
|
@@ -441,85 +443,6 @@ declare function runDoctorConflictLint(projectRoot: string, opts?: {
|
|
|
441
443
|
judge?: ConflictJudge;
|
|
442
444
|
}): Promise<ConflictLintReport>;
|
|
443
445
|
|
|
444
|
-
type KnowledgeMetaBuildSource = "doctor_fix" | "sync_meta";
|
|
445
|
-
type KnowledgeMetaBuildResult = {
|
|
446
|
-
meta: AgentsMeta;
|
|
447
|
-
knowledgeTestIndex: KnowledgeTestIndex;
|
|
448
|
-
changed: boolean;
|
|
449
|
-
};
|
|
450
|
-
type WriteKnowledgeMetaOptions = {
|
|
451
|
-
source: KnowledgeMetaBuildSource;
|
|
452
|
-
};
|
|
453
|
-
/**
|
|
454
|
-
* v2.0-rc.24 TASK-07: Load a Map<stable_id, knowledge_type> from the
|
|
455
|
-
* project's `.fabric/agents.meta.json`. Consumed by the doctor cite-coverage
|
|
456
|
-
* routing (TASK-08) to dispatch cites to the correct policy bucket
|
|
457
|
-
* (decision/pitfall = strict contract / model = reference-only /
|
|
458
|
-
* guideline+process = deferred to rc.25 LLM-judge). Cited ids absent from
|
|
459
|
-
* this map fall into the `cite_id_unresolved` bucket.
|
|
460
|
-
*
|
|
461
|
-
* **Plural knowledge_type contract (rc.29 BUG-C1 unification):** the returned
|
|
462
|
-
* map values are the PLURAL `KnowledgeType` enum (`"models" | "decisions" |
|
|
463
|
-
* "guidelines" | "pitfalls" | "processes"`) — matching disk frontmatter,
|
|
464
|
-
* filesystem layout, MCP I/O surface, and the canonical `KnowledgeTypeSchema`
|
|
465
|
-
* exported from `@fenglimg/fabric-shared`. Legacy singular frontmatter is
|
|
466
|
-
* normalized at parse time (see `SINGULAR_TO_PLURAL` in `parseFrontmatter`);
|
|
467
|
-
* downstream callers (TASK-08 doctor) match against the plural enum.
|
|
468
|
-
*
|
|
469
|
-
* Both team (KT-*) and personal (KP-*) entries are included — they live in
|
|
470
|
-
* the same `meta.nodes` map.
|
|
471
|
-
*
|
|
472
|
-
* Graceful on failure: a missing meta file, malformed JSON, or schema
|
|
473
|
-
* validation failure all yield an empty Map (no throw). The doctor will then
|
|
474
|
-
* surface every cite as `cite_id_unresolved`, which is the safe degraded
|
|
475
|
-
* mode.
|
|
476
|
-
*/
|
|
477
|
-
declare function loadKbIdTypeMap(projectRootInput: string): Promise<Map<string, KnowledgeType>>;
|
|
478
|
-
declare function buildKnowledgeMeta(projectRootInput: string): Promise<KnowledgeMetaBuildResult>;
|
|
479
|
-
declare function writeKnowledgeMeta(projectRootInput: string, options: WriteKnowledgeMetaOptions): Promise<KnowledgeMetaBuildResult>;
|
|
480
|
-
declare function computeKnowledgeBasedAgentsMeta(projectRootInput: string, existingMeta?: AgentsMeta): Promise<AgentsMeta>;
|
|
481
|
-
declare function computeKnowledgeTestIndex(projectRootInput: string, computedMeta: AgentsMeta, previousIndex?: KnowledgeTestIndex): Promise<KnowledgeTestIndex>;
|
|
482
|
-
declare function deriveKnowledgeMetaLayer(relativePath: string): AgentsLayer;
|
|
483
|
-
declare function deriveKnowledgeMetaTopologyType(relativePath: string): AgentsTopologyType;
|
|
484
|
-
declare function isSameKnowledgeTestIndex(left: KnowledgeTestIndex, right: KnowledgeTestIndex): boolean;
|
|
485
|
-
declare function stableStringify(value: unknown): string;
|
|
486
|
-
|
|
487
|
-
/**
|
|
488
|
-
* v2.0 KnowledgeIdAllocator
|
|
489
|
-
*
|
|
490
|
-
* Wraps the pure `allocateKnowledgeId` allocator with persistence: it reads
|
|
491
|
-
* `agents.meta.json`, advances the counter for the requested (layer, type)
|
|
492
|
-
* pair, and writes the updated meta atomically (write-to-tmp + rename) so
|
|
493
|
-
* concurrent readers always see a consistent file.
|
|
494
|
-
*
|
|
495
|
-
* Counters are MONOTONIC across the lifetime of the meta file: deleting a
|
|
496
|
-
* knowledge entry does NOT free its counter slot, so previously-allocated
|
|
497
|
-
* stable_ids remain unique even after their files are removed.
|
|
498
|
-
*
|
|
499
|
-
* Key invariants:
|
|
500
|
-
* - Counters envelope is initialized to zeros if absent (v1.x meta compat).
|
|
501
|
-
* - Each allocate() call performs read → mutate → atomic-write in sequence.
|
|
502
|
-
* - The returned id is guaranteed to differ from every previously-returned
|
|
503
|
-
* id for the same meta path.
|
|
504
|
-
*/
|
|
505
|
-
declare class KnowledgeIdAllocator {
|
|
506
|
-
private readonly metaPath;
|
|
507
|
-
constructor(metaPath: string);
|
|
508
|
-
/**
|
|
509
|
-
* Allocate the next stable_id for the given (layer, type) pair and persist
|
|
510
|
-
* the advanced counter to `agents.meta.json`.
|
|
511
|
-
*/
|
|
512
|
-
allocate(layer: Layer, type: KnowledgeType): Promise<StableId>;
|
|
513
|
-
/**
|
|
514
|
-
* Returns the current counters envelope, defaulting to all-zero slots when
|
|
515
|
-
* the meta file is absent or pre-v2.0 (counters key missing).
|
|
516
|
-
*/
|
|
517
|
-
getCounters(): Promise<AgentsMetaCounters>;
|
|
518
|
-
private readMeta;
|
|
519
|
-
private normalizeCounters;
|
|
520
|
-
private writeMetaAtomic;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
446
|
/**
|
|
524
447
|
* Append-evidence-on-collision service for fab_extract_knowledge.
|
|
525
448
|
*
|
|
@@ -762,16 +685,15 @@ interface KnowledgeSyncOptions {
|
|
|
762
685
|
/** When true, invalid frontmatter throws RuleValidationError (default: false — collect as warning). */
|
|
763
686
|
throwOnInvalidFrontmatter?: boolean;
|
|
764
687
|
/**
|
|
765
|
-
* v2.0.0-rc.29 TASK-005 (BUG-G1):
|
|
766
|
-
*
|
|
767
|
-
*
|
|
768
|
-
*
|
|
769
|
-
*
|
|
770
|
-
*
|
|
771
|
-
*
|
|
772
|
-
*
|
|
773
|
-
*
|
|
774
|
-
* (~7%) because the hot path emitted detect-only events.
|
|
688
|
+
* v2.0.0-rc.29 TASK-005 (BUG-G1): originally opted the hot path into a
|
|
689
|
+
* follow-up `reconcileKnowledge` (rewrite agents.meta.json) so every
|
|
690
|
+
* detected drift got a paired heal event.
|
|
691
|
+
*
|
|
692
|
+
* v2.2 W5 R2 (agents.meta decolo): retained as a NO-OP for backward
|
|
693
|
+
* compatibility — the co-location agents.meta.json it used to rebuild no
|
|
694
|
+
* longer exists (knowledge lives in stores; read paths cut over to the
|
|
695
|
+
* cross-store model). MCP tool call sites still pass `autoHealOnDrift: true`;
|
|
696
|
+
* it is now ignored.
|
|
775
697
|
*/
|
|
776
698
|
autoHealOnDrift?: boolean;
|
|
777
699
|
}
|
|
@@ -816,32 +738,6 @@ declare function invalidateKnowledgeSyncCooldown(projectRoot: string): void;
|
|
|
816
738
|
* hot-path consumers (MCP tools).
|
|
817
739
|
*/
|
|
818
740
|
declare function ensureKnowledgeFresh(projectRoot: string, opts?: KnowledgeSyncOptions): Promise<KnowledgeSyncReport>;
|
|
819
|
-
interface ReconcileKnowledgeOptions {
|
|
820
|
-
/**
|
|
821
|
-
* Identifies who triggered the reconcile; controls which summary ledger event is written.
|
|
822
|
-
*
|
|
823
|
-
* v2.0.0-rc.23 TASK-005 (a-B): `auto-heal-description` added so plan_context
|
|
824
|
-
* can drive a full reconcile when it detects nodes with `description === undefined`
|
|
825
|
-
* (legacy meta drift the revision-hash gate cannot detect).
|
|
826
|
-
*
|
|
827
|
-
* v2.0.0-rc.27 TASK-001 (§2.9 root): `post-approve` / `post-modify` added so
|
|
828
|
-
* `fab_review` approve/modify-layer-flip can drive an immediate meta rebuild
|
|
829
|
-
* — without this the new entry's `nodes[id]` stays empty until the next
|
|
830
|
-
* plan_context call's auto-heal, which leaves the entry undiscoverable in
|
|
831
|
-
* the description_index window between approve and the next hint call.
|
|
832
|
-
*/
|
|
833
|
-
trigger?: "startup" | "doctor" | "manual" | "auto-heal-description" | "auto-heal-after-drift" | "post-approve" | "post-modify";
|
|
834
|
-
}
|
|
835
|
-
/**
|
|
836
|
-
* Full scan + rewrites agents.meta.json with ground-truth disk state + emits
|
|
837
|
-
* ledger events. Used by startup (TASK-022) and doctor repair (TASK-023).
|
|
838
|
-
* Returns reconciled_files listing all paths whose meta was updated.
|
|
839
|
-
*
|
|
840
|
-
* When `opts.trigger` is `'startup'`, a `meta_reconciled_on_startup` summary
|
|
841
|
-
* ledger event is appended after per-file drift events. Other trigger values
|
|
842
|
-
* append a `meta_reconciled` event. Omitting the trigger skips the summary.
|
|
843
|
-
*/
|
|
844
|
-
declare function reconcileKnowledge(projectRoot: string, opts?: ReconcileKnowledgeOptions): Promise<KnowledgeSyncReport>;
|
|
845
741
|
|
|
846
742
|
type LedgerSourceFilter = "ai" | "human";
|
|
847
743
|
type StoredLedgerEntry = LedgerEntry & {
|
|
@@ -877,40 +773,6 @@ type RehydratedAgentsMetaSnapshot = {
|
|
|
877
773
|
};
|
|
878
774
|
declare function rehydrateAgentsMetaAt(projectRoot: string, target: RehydrateTarget): Promise<RehydratedAgentsMetaSnapshot>;
|
|
879
775
|
|
|
880
|
-
declare function readAgentsMeta(projectRoot: string): Promise<AgentsMeta>;
|
|
881
|
-
|
|
882
|
-
type KnowledgeEntryItem = {
|
|
883
|
-
path: string;
|
|
884
|
-
content: string;
|
|
885
|
-
};
|
|
886
|
-
type DescriptionStub = {
|
|
887
|
-
path: string;
|
|
888
|
-
description: string;
|
|
889
|
-
};
|
|
890
|
-
type HumanLockedNearby = {
|
|
891
|
-
file: string;
|
|
892
|
-
excerpt: string;
|
|
893
|
-
};
|
|
894
|
-
type KnowledgePayload = {
|
|
895
|
-
L0: string;
|
|
896
|
-
L1: KnowledgeEntryItem[];
|
|
897
|
-
L2: KnowledgeEntryItem[];
|
|
898
|
-
human_locked_nearby: HumanLockedNearby[];
|
|
899
|
-
description_stubs?: DescriptionStub[];
|
|
900
|
-
};
|
|
901
|
-
type GetKnowledgeInput = {
|
|
902
|
-
path: string;
|
|
903
|
-
client_hash?: string;
|
|
904
|
-
correlation_id?: string;
|
|
905
|
-
session_id?: string;
|
|
906
|
-
};
|
|
907
|
-
type GetKnowledgeResult = {
|
|
908
|
-
revision_hash: string;
|
|
909
|
-
stale: boolean;
|
|
910
|
-
rules: KnowledgePayload;
|
|
911
|
-
};
|
|
912
|
-
declare function getKnowledge(projectRoot: string, input: GetKnowledgeInput): Promise<GetKnowledgeResult>;
|
|
913
|
-
|
|
914
776
|
/**
|
|
915
777
|
* Shared constants used across the server package.
|
|
916
778
|
*/
|
|
@@ -953,4 +815,4 @@ interface ShutdownHandlerDeps {
|
|
|
953
815
|
*/
|
|
954
816
|
declare function createShutdownHandler(deps: ShutdownHandlerDeps): () => void;
|
|
955
817
|
|
|
956
|
-
export { AGENTS_MD_RESOURCE_URI, type ArchiveHistoryEntry, type ArchiveHistoryReport, type CiteCoverageReport, type ConflictEntry, type ConflictJudge, type ConflictLintReport, type ConflictPair, type ConflictVerdict, DEFAULT_CONFLICT_SIMILARITY_THRESHOLD, 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,
|
|
818
|
+
export { AGENTS_MD_RESOURCE_URI, type ArchiveHistoryEntry, type ArchiveHistoryReport, type CiteCoverageReport, type ConflictEntry, type ConflictJudge, type ConflictLintReport, type ConflictPair, type ConflictVerdict, DEFAULT_CONFLICT_SIMILARITY_THRESHOLD, 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, 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 RequirementProfile, type SelectionTokenState, type ShutdownHandlerDeps, type StructuredWarning, appendEventLedgerEvent, bumpCounter, contextCache, createFabricServer, createInFlightTracker, createShutdownHandler, drainCounters, enrichDescriptions, ensureKnowledgeFresh, extractKnowledge, findConflictCandidates, flushAndSyncEventLedger, flushMetrics, formatPreexistingRootMessage, getEventLedgerPath, getLedgerPath, getLegacyLedgerPath, getMetricsLedgerPath, invalidateKnowledgeSyncCooldown, lintConflicts, loadConflictEntries, pairSimilarity, planContext, readEventLedger, readLedger, readMetrics, readSelectionToken, recall, rehydrateAgentsMetaAt, resolveLedgerPaths, reviewKnowledge, runDoctorApplyLint, runDoctorArchiveHistory, runDoctorCiteCoverage, runDoctorConflictLint, runDoctorFix, runDoctorHistoryAll, runDoctorReport, startMetricsFlush, startRotationTick, startStdioServer, stopMetricsFlush, stopRotationTick };
|