@fenglimg/fabric-server 2.0.0-rc.15 → 2.0.0-rc.22
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
CHANGED
|
@@ -97,6 +97,27 @@ type DoctorApplyLintReport = {
|
|
|
97
97
|
declare function runDoctorReport(target: string): Promise<DoctorReport>;
|
|
98
98
|
declare function runDoctorFix(target: string): Promise<DoctorFixReport>;
|
|
99
99
|
declare function runDoctorApplyLint(target: string): Promise<DoctorApplyLintReport>;
|
|
100
|
+
type CiteCoverageReport = {
|
|
101
|
+
status: "ok" | "skipped";
|
|
102
|
+
marker_ts: number;
|
|
103
|
+
marker_emitted_now: boolean;
|
|
104
|
+
since_ts: number;
|
|
105
|
+
client_filter: "cc" | "codex" | "cursor" | "all";
|
|
106
|
+
metrics: {
|
|
107
|
+
edits_touched: number;
|
|
108
|
+
qualifying_cites: number;
|
|
109
|
+
recalled_unverified: number;
|
|
110
|
+
expected_but_missed: number;
|
|
111
|
+
total_turns: number;
|
|
112
|
+
};
|
|
113
|
+
per_client?: Record<string, Partial<CiteCoverageReport["metrics"]>>;
|
|
114
|
+
dismissed_reason_histogram?: Record<string, number>;
|
|
115
|
+
generated_at: string;
|
|
116
|
+
};
|
|
117
|
+
declare function runDoctorCiteCoverage(projectRoot: string, options: {
|
|
118
|
+
since: number;
|
|
119
|
+
client: "cc" | "codex" | "cursor" | "all";
|
|
120
|
+
}): Promise<CiteCoverageReport>;
|
|
100
121
|
|
|
101
122
|
type KnowledgeMetaBuildSource = "doctor_fix" | "sync_meta";
|
|
102
123
|
type KnowledgeMetaBuildResult = {
|
|
@@ -235,6 +256,8 @@ type PlanContextResult = {
|
|
|
235
256
|
path?: string;
|
|
236
257
|
}>;
|
|
237
258
|
};
|
|
259
|
+
auto_healed?: boolean;
|
|
260
|
+
previous_revision_hash?: string;
|
|
238
261
|
};
|
|
239
262
|
type SelectionTokenState = {
|
|
240
263
|
token: string;
|
|
@@ -382,4 +405,4 @@ declare function startHttpServer(options: {
|
|
|
382
405
|
authToken?: string;
|
|
383
406
|
}): Promise<Server>;
|
|
384
407
|
|
|
385
|
-
export { AGENTS_MD_RESOURCE_URI, type AcquireOptions, type DoctorApplyLintMutation, type DoctorApplyLintMutationKind, type DoctorApplyLintReport, type DoctorFixReport, type DoctorIssue, type DoctorReport, EVENT_LEDGER_PATH, type InFlightTracker, KnowledgeIdAllocator, type KnowledgeMetaBuildResult, type KnowledgeMetaBuildSource, type KnowledgeSyncLedgerEvent, type KnowledgeSyncOptions, type KnowledgeSyncReport, LEDGER_PATH, LEGACY_LEDGER_PATH, type LedgerEvent, type LockState, type PlanContextInput, type PlanContextResult, type ReconcileKnowledgeOptions, type RequirementProfile, type SelectionTokenState, ServeLockHeldError, type ShutdownHandlerDeps, type StructuredWarning, type WriteKnowledgeMetaOptions, acquireLock, appendEventLedgerEvent, buildKnowledgeMeta, checkLockOrThrow, computeKnowledgeBasedAgentsMeta, computeKnowledgeTestIndex, createFabricServer, createInFlightTracker, createShutdownHandler, deriveKnowledgeMetaLayer, deriveKnowledgeMetaTopologyType, ensureKnowledgeFresh, extractKnowledge, flushAndSyncEventLedger, formatPreexistingRootMessage, getEventLedgerPath, getLedgerPath, getLegacyLedgerPath, isSameKnowledgeTestIndex, planContext, readLockState, readSelectionToken, reconcileKnowledge, releaseLock, reviewKnowledge, runDoctorApplyLint, runDoctorFix, runDoctorReport, stableStringify, startHttpServer, startStdioServer, writeKnowledgeMeta };
|
|
408
|
+
export { AGENTS_MD_RESOURCE_URI, type AcquireOptions, type CiteCoverageReport, type DoctorApplyLintMutation, type DoctorApplyLintMutationKind, type DoctorApplyLintReport, type DoctorFixReport, type DoctorIssue, type DoctorReport, EVENT_LEDGER_PATH, type InFlightTracker, KnowledgeIdAllocator, type KnowledgeMetaBuildResult, type KnowledgeMetaBuildSource, type KnowledgeSyncLedgerEvent, type KnowledgeSyncOptions, type KnowledgeSyncReport, LEDGER_PATH, LEGACY_LEDGER_PATH, type LedgerEvent, type LockState, type PlanContextInput, type PlanContextResult, type ReconcileKnowledgeOptions, type RequirementProfile, type SelectionTokenState, ServeLockHeldError, type ShutdownHandlerDeps, type StructuredWarning, type WriteKnowledgeMetaOptions, acquireLock, appendEventLedgerEvent, buildKnowledgeMeta, checkLockOrThrow, computeKnowledgeBasedAgentsMeta, computeKnowledgeTestIndex, createFabricServer, createInFlightTracker, createShutdownHandler, deriveKnowledgeMetaLayer, deriveKnowledgeMetaTopologyType, ensureKnowledgeFresh, extractKnowledge, flushAndSyncEventLedger, formatPreexistingRootMessage, getEventLedgerPath, getLedgerPath, getLegacyLedgerPath, isSameKnowledgeTestIndex, planContext, readLockState, readSelectionToken, reconcileKnowledge, releaseLock, reviewKnowledge, runDoctorApplyLint, runDoctorCiteCoverage, runDoctorFix, runDoctorReport, stableStringify, startHttpServer, startStdioServer, writeKnowledgeMeta };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AgentsMetaFileMissingError,
|
|
2
3
|
EVENT_LEDGER_PATH,
|
|
3
4
|
LEDGER_PATH,
|
|
4
5
|
LEGACY_LEDGER_PATH,
|
|
@@ -16,17 +17,19 @@ import {
|
|
|
16
17
|
getLedgerPath,
|
|
17
18
|
getLegacyLedgerPath,
|
|
18
19
|
isSameKnowledgeTestIndex,
|
|
20
|
+
loadActiveMeta,
|
|
21
|
+
loadActiveMetaOrStale,
|
|
19
22
|
normalizeKnowledgePath,
|
|
20
|
-
readAgentsMeta,
|
|
21
23
|
reconcileKnowledge,
|
|
22
24
|
resolveProjectRoot,
|
|
23
25
|
runDoctorApplyLint,
|
|
26
|
+
runDoctorCiteCoverage,
|
|
24
27
|
runDoctorFix,
|
|
25
28
|
runDoctorReport,
|
|
26
29
|
sha256,
|
|
27
30
|
stableStringify,
|
|
28
31
|
writeKnowledgeMeta
|
|
29
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-7N3FW5LX.js";
|
|
30
33
|
|
|
31
34
|
// src/index.ts
|
|
32
35
|
import { existsSync as existsSync4 } from "fs";
|
|
@@ -122,6 +125,13 @@ function resolvePersonalRoot() {
|
|
|
122
125
|
return process.env.FABRIC_HOME ?? homedir();
|
|
123
126
|
}
|
|
124
127
|
async function extractKnowledge(projectRoot, input) {
|
|
128
|
+
try {
|
|
129
|
+
await loadActiveMeta(projectRoot, { caller: "extractKnowledge" });
|
|
130
|
+
} catch (error) {
|
|
131
|
+
if (!(error instanceof AgentsMetaFileMissingError)) {
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
125
135
|
const sanitizedSlug = sanitizeSlug(input.slug);
|
|
126
136
|
const sourceSessions = Array.isArray(input.source_sessions) && input.source_sessions.length > 0 ? input.source_sessions : input.source_session !== void 0 && input.source_session.length > 0 ? [input.source_session] : [];
|
|
127
137
|
const primarySession = sourceSessions[0] ?? "";
|
|
@@ -454,8 +464,9 @@ import { deriveAgentsMetaLayer } from "@fenglimg/fabric-shared";
|
|
|
454
464
|
var SELECTION_TOKEN_TTL_MS = 5 * 60 * 1e3;
|
|
455
465
|
var selectionTokenCache = /* @__PURE__ */ new Map();
|
|
456
466
|
async function planContext(projectRoot, input) {
|
|
457
|
-
const
|
|
458
|
-
const
|
|
467
|
+
const metaResult = await loadActiveMetaOrStale(projectRoot, { caller: "planContext" });
|
|
468
|
+
const meta = metaResult.meta;
|
|
469
|
+
const stale = metaResult.degraded === true || input.client_hash !== void 0 && input.client_hash !== meta.revision;
|
|
459
470
|
const uniquePaths = dedupePaths(input.paths);
|
|
460
471
|
const allDescriptions = buildDescriptionIndex(meta);
|
|
461
472
|
const relevanceTargetPaths = input.target_paths ?? uniquePaths;
|
|
@@ -479,7 +490,14 @@ async function planContext(projectRoot, input) {
|
|
|
479
490
|
shared: {
|
|
480
491
|
description_index: sharedDescriptionIndex,
|
|
481
492
|
preflight_diagnostics: buildPreflightDiagnostics(meta)
|
|
482
|
-
}
|
|
493
|
+
},
|
|
494
|
+
// v2.0.0-rc.22 Scope D T-D2: surface auto-heal pair only when a heal
|
|
495
|
+
// actually fired. Keeping these fields absent on the steady-state path
|
|
496
|
+
// means existing consumers see the same wire shape they always have.
|
|
497
|
+
...metaResult.auto_healed ? {
|
|
498
|
+
auto_healed: true,
|
|
499
|
+
previous_revision_hash: metaResult.previous_revision_hash
|
|
500
|
+
} : {}
|
|
483
501
|
};
|
|
484
502
|
try {
|
|
485
503
|
await appendEventLedgerEvent(projectRoot, {
|
|
@@ -1567,7 +1585,7 @@ async function getKnowledgeSections(projectRoot, input) {
|
|
|
1567
1585
|
throw new Error("selection_token is missing or expired");
|
|
1568
1586
|
}
|
|
1569
1587
|
validateAiSelections(token.ai_selectable_stable_ids, input.ai_selected_stable_ids, input.ai_selection_reasons);
|
|
1570
|
-
const meta = await
|
|
1588
|
+
const { meta } = await loadActiveMeta(projectRoot, { caller: "getKnowledgeSections" });
|
|
1571
1589
|
const selectedStableIds = [...token.required_stable_ids, ...input.ai_selected_stable_ids];
|
|
1572
1590
|
const selectedRules = sortRuleNodes(selectedStableIds.map((stableId) => findRuleNode(meta, stableId)));
|
|
1573
1591
|
const diagnostics = [];
|
|
@@ -1892,7 +1910,7 @@ function formatPreexistingRootMessage(projectRoot) {
|
|
|
1892
1910
|
function createFabricServer(tracker) {
|
|
1893
1911
|
const server = new McpServer({
|
|
1894
1912
|
name: "fabric-knowledge-server",
|
|
1895
|
-
version: "2.0.0-rc.
|
|
1913
|
+
version: "2.0.0-rc.22"
|
|
1896
1914
|
});
|
|
1897
1915
|
registerPlanContext(server, tracker);
|
|
1898
1916
|
registerKnowledgeSections(server, tracker);
|
|
@@ -1992,7 +2010,7 @@ function createShutdownHandler(deps) {
|
|
|
1992
2010
|
};
|
|
1993
2011
|
}
|
|
1994
2012
|
async function startHttpServer(options) {
|
|
1995
|
-
const { createFabricHttpApp } = await import("./http-
|
|
2013
|
+
const { createFabricHttpApp } = await import("./http-FF5NZCJK.js");
|
|
1996
2014
|
const { port, projectRoot, host = "127.0.0.1", authToken } = options;
|
|
1997
2015
|
const app = createFabricHttpApp({ projectRoot, host, authToken });
|
|
1998
2016
|
return await new Promise((resolveServer, rejectServer) => {
|
|
@@ -2050,6 +2068,7 @@ export {
|
|
|
2050
2068
|
releaseLock,
|
|
2051
2069
|
reviewKnowledge,
|
|
2052
2070
|
runDoctorApplyLint,
|
|
2071
|
+
runDoctorCiteCoverage,
|
|
2053
2072
|
runDoctorFix,
|
|
2054
2073
|
runDoctorReport,
|
|
2055
2074
|
stableStringify,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fenglimg/fabric-server",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"express": "^5.2.1",
|
|
14
14
|
"minimatch": "^10.0.1",
|
|
15
15
|
"zod": "^3.25.0",
|
|
16
|
-
"@fenglimg/fabric-shared": "2.0.0-rc.
|
|
16
|
+
"@fenglimg/fabric-shared": "2.0.0-rc.22"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/express": "^5.0.6",
|