@fenglimg/fabric-server 2.0.0-rc.21 → 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.
@@ -14,7 +14,7 @@ import {
14
14
  readEventLedger,
15
15
  runDoctorReport,
16
16
  sha256
17
- } from "./chunk-7R6MFA7Y.js";
17
+ } from "./chunk-7N3FW5LX.js";
18
18
 
19
19
  // src/http.ts
20
20
  import { randomUUID as randomUUID2 } from "crypto";
package/dist/index.d.ts CHANGED
@@ -256,6 +256,8 @@ type PlanContextResult = {
256
256
  path?: string;
257
257
  }>;
258
258
  };
259
+ auto_healed?: boolean;
260
+ previous_revision_hash?: string;
259
261
  };
260
262
  type SelectionTokenState = {
261
263
  token: string;
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,8 +17,9 @@ 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,
@@ -27,7 +29,7 @@ import {
27
29
  sha256,
28
30
  stableStringify,
29
31
  writeKnowledgeMeta
30
- } from "./chunk-7R6MFA7Y.js";
32
+ } from "./chunk-7N3FW5LX.js";
31
33
 
32
34
  // src/index.ts
33
35
  import { existsSync as existsSync4 } from "fs";
@@ -123,6 +125,13 @@ function resolvePersonalRoot() {
123
125
  return process.env.FABRIC_HOME ?? homedir();
124
126
  }
125
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
+ }
126
135
  const sanitizedSlug = sanitizeSlug(input.slug);
127
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] : [];
128
137
  const primarySession = sourceSessions[0] ?? "";
@@ -455,8 +464,9 @@ import { deriveAgentsMetaLayer } from "@fenglimg/fabric-shared";
455
464
  var SELECTION_TOKEN_TTL_MS = 5 * 60 * 1e3;
456
465
  var selectionTokenCache = /* @__PURE__ */ new Map();
457
466
  async function planContext(projectRoot, input) {
458
- const meta = await readAgentsMeta(projectRoot);
459
- const stale = input.client_hash !== void 0 && input.client_hash !== meta.revision;
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;
460
470
  const uniquePaths = dedupePaths(input.paths);
461
471
  const allDescriptions = buildDescriptionIndex(meta);
462
472
  const relevanceTargetPaths = input.target_paths ?? uniquePaths;
@@ -480,7 +490,14 @@ async function planContext(projectRoot, input) {
480
490
  shared: {
481
491
  description_index: sharedDescriptionIndex,
482
492
  preflight_diagnostics: buildPreflightDiagnostics(meta)
483
- }
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
+ } : {}
484
501
  };
485
502
  try {
486
503
  await appendEventLedgerEvent(projectRoot, {
@@ -1568,7 +1585,7 @@ async function getKnowledgeSections(projectRoot, input) {
1568
1585
  throw new Error("selection_token is missing or expired");
1569
1586
  }
1570
1587
  validateAiSelections(token.ai_selectable_stable_ids, input.ai_selected_stable_ids, input.ai_selection_reasons);
1571
- const meta = await readAgentsMeta(projectRoot);
1588
+ const { meta } = await loadActiveMeta(projectRoot, { caller: "getKnowledgeSections" });
1572
1589
  const selectedStableIds = [...token.required_stable_ids, ...input.ai_selected_stable_ids];
1573
1590
  const selectedRules = sortRuleNodes(selectedStableIds.map((stableId) => findRuleNode(meta, stableId)));
1574
1591
  const diagnostics = [];
@@ -1893,7 +1910,7 @@ function formatPreexistingRootMessage(projectRoot) {
1893
1910
  function createFabricServer(tracker) {
1894
1911
  const server = new McpServer({
1895
1912
  name: "fabric-knowledge-server",
1896
- version: "2.0.0-rc.21"
1913
+ version: "2.0.0-rc.22"
1897
1914
  });
1898
1915
  registerPlanContext(server, tracker);
1899
1916
  registerKnowledgeSections(server, tracker);
@@ -1993,7 +2010,7 @@ function createShutdownHandler(deps) {
1993
2010
  };
1994
2011
  }
1995
2012
  async function startHttpServer(options) {
1996
- const { createFabricHttpApp } = await import("./http-JGWQGUZS.js");
2013
+ const { createFabricHttpApp } = await import("./http-FF5NZCJK.js");
1997
2014
  const { port, projectRoot, host = "127.0.0.1", authToken } = options;
1998
2015
  const app = createFabricHttpApp({ projectRoot, host, authToken });
1999
2016
  return await new Promise((resolveServer, rejectServer) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fenglimg/fabric-server",
3
- "version": "2.0.0-rc.21",
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.21"
16
+ "@fenglimg/fabric-shared": "2.0.0-rc.22"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@types/express": "^5.0.6",