@fenglimg/fabric-shared 2.3.0-rc.1 → 2.3.0-rc.10

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.
@@ -151,11 +151,15 @@ var mountedStoreSchema = z.object({
151
151
  // Git remote locator for this clone, if any. Absent = local-only store
152
152
  // (valid; doctor nudges to add a remote for backup — R5#5, P6).
153
153
  remote: z.string().min(1).optional(),
154
- // v2.1.0-rc.1 P3: marks the implicit personal store (the one minted by
155
- // `install --global`). Exactly one mounted store carries personal=true; it
156
- // is the write target for personal-scope entries (R5#3) and always in the
157
- // read-set (S11). Optional (no default) so the output type stays a plain
158
- // optional consumers coalesce `?? false` when building resolver input.
154
+ // v2.1.0-rc.1 P3: marks a personal store (the kind minted by
155
+ // `install --global`). 语义 A (multi-personal): MULTIPLE mounted stores may
156
+ // carry personal=true a machine can mount several personal stores and
157
+ // switch which is ACTIVE via globalConfig.active_personal_store. The ACTIVE
158
+ // personal is the write target for personal-scope entries (R5#3) and the one
159
+ // in the read-set (S11); non-active personal stores stay mounted but out of
160
+ // the read-set. Absent active pointer ⇒ resolver falls back to the first
161
+ // mounted personal (back-compat). Optional (no default) so the output type
162
+ // stays a plain optional — consumers coalesce `?? false`.
159
163
  personal: z.boolean().optional(),
160
164
  // Whether writes are accepted into this store from this machine. Optional;
161
165
  // consumers coalesce `?? true`. Shared stores cloned read-only set false.
@@ -174,15 +178,34 @@ var globalConfigSchema = z.object({
174
178
  // All stores mounted on this machine. The implicit personal store is
175
179
  // included here once initialized. Default empty so a fresh global config
176
180
  // (before `install --global`) parses cleanly.
177
- stores: z.array(mountedStoreSchema).optional().default([])
181
+ stores: z.array(mountedStoreSchema).optional().default([]),
182
+ // 语义 A (multi-personal): alias/UUID of the ACTIVE personal store among the
183
+ // possibly-many `personal:true` stores in `stores[]`. Machine-wide (personal
184
+ // is uid-scoped identity, KT-DEC-0020) — switching it in any repo takes
185
+ // effect everywhere. Set by `fabric store switch-personal <alias>` and the
186
+ // install personal slot. Absent ⇒ the resolver falls back to the first
187
+ // mounted personal, so legacy single-personal configs are unchanged.
188
+ active_personal_store: z.string().min(1).optional()
178
189
  }).passthrough();
179
190
 
180
191
  // src/store/global-config-io.ts
181
192
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
182
193
  import { homedir } from "os";
183
194
  import { join } from "path";
195
+ function isTestRuntime() {
196
+ return process.env.VITEST !== void 0 || process.env.VITEST_WORKER_ID !== void 0;
197
+ }
184
198
  function resolveGlobalRoot() {
185
- return join(process.env.FABRIC_HOME ?? homedir(), ".fabric");
199
+ const fabricHome = process.env.FABRIC_HOME;
200
+ if (fabricHome !== void 0 && fabricHome !== "") {
201
+ return join(fabricHome, ".fabric");
202
+ }
203
+ if (isTestRuntime()) {
204
+ throw new Error(
205
+ "resolveGlobalRoot(): FABRIC_HOME must be set under the test runner \u2014 refusing to fall back to the real home dir (~/.fabric). Repoint process.env.FABRIC_HOME to an isolated temp dir in beforeEach (see plan-context.test.ts for the pattern)."
206
+ );
207
+ }
208
+ return join(homedir(), ".fabric");
186
209
  }
187
210
  function globalConfigPath(globalRoot = resolveGlobalRoot()) {
188
211
  return join(globalRoot, "fabric-global.json");
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveGlobalLocale
3
- } from "./chunk-2GLIAZ5M.js";
3
+ } from "./chunk-ASS2KBB7.js";
4
4
 
5
5
  // src/templates/bootstrap-canonical.ts
6
6
  var BOOTSTRAP_MARKER_BEGIN = "<!-- fabric:bootstrap:begin -->";
@@ -47,21 +47,25 @@ var structuredWarningSchema = z3.object({
47
47
  });
48
48
  var _knowledgeTypeEnum = z3.enum(["models", "decisions", "guidelines", "pitfalls", "processes"]);
49
49
  var _maturityEnum = z3.enum(["draft", "verified", "proven"]);
50
- var _layerEnum = z3.enum(["personal", "team"]);
51
50
  var _ruleDescriptionSchema = z3.object({
52
51
  summary: z3.string(),
53
52
  intent_clues: z3.array(z3.string()),
54
- tech_stack: z3.array(z3.string()),
55
- impact: z3.array(z3.string()),
53
+ // wire-slim (payload): fab_recall projects a LEAN description (summary +
54
+ // must_read_if + intent_clues + knowledge_type — the selection signal), leaving
55
+ // tech_stack/impact to be Read on demand via read_path (KT-DEC-0026 lean
56
+ // contract at the field level). So they are optional on the wire. plan-context
57
+ // still returns them in full — zod keeps optional-present values, only ABSENT is
58
+ // now allowed, so no plan-context consumer regresses.
59
+ tech_stack: z3.array(z3.string()).optional(),
60
+ impact: z3.array(z3.string()).optional(),
56
61
  must_read_if: z3.string(),
57
- entities: z3.array(z3.string()).optional(),
58
62
  // v2.0: optional knowledge-entry fields. Absent for v1.x rules; present for
59
- // entries that declare frontmatter `id/type/maturity/layer`.
63
+ // entries that declare frontmatter `id/type/maturity`. W4/Track1: the redundant
64
+ // `knowledge_layer` field was removed — a candidate's layer is derived from its
65
+ // stable_id prefix (KP-→personal, else team; KT-DEC-0004).
60
66
  id: z3.string().optional(),
61
67
  knowledge_type: _knowledgeTypeEnum.optional(),
62
68
  maturity: _maturityEnum.optional(),
63
- knowledge_layer: _layerEnum.optional(),
64
- layer_reason: z3.string().optional(),
65
69
  created_at: z3.string().optional(),
66
70
  // v2.0.0-rc.38 UX-3 (D-MCP fold ③): these three were previously carried ONLY
67
71
  // as top-level mirrors on the index item. With the mirrors removed,
@@ -75,7 +79,12 @@ var _ruleDescriptionSchema = z3.object({
75
79
  // schema must also carry `related`, else zod strips the graph edges on output
76
80
  // validation and they never reach the client (MC1 include_related / fabric-
77
81
  // connect would see nothing). Mirrors the agents-meta ruleDescriptionSchema.
78
- related: z3.array(z3.string()).optional()
82
+ related: z3.array(z3.string()).optional(),
83
+ // v2.2 glossary aliases FIELD (C-001): mirrors agents.ts RuleDescription.
84
+ // MUST be declared here or zod .strip() drops aliases on output validation
85
+ // before plan-context feeds them into the BM25 body — long-tail alias terms
86
+ // would never reach the lexical/vector index (KT-PIT-0018 zod-strip lesson).
87
+ aliases: z3.array(z3.string()).optional()
79
88
  });
80
89
  var _descriptionIndexItemSchema = z3.object({
81
90
  stable_id: z3.string(),
@@ -194,7 +203,11 @@ var planContextHintNarrowEntrySchema = z3.object({
194
203
  // W2-2 (KT-DEC-0027): the entry's must_read_if trigger hook, forwarded for the
195
204
  // SessionStart REFERENCE rendering (decision/pitfall/process → title + hook).
196
205
  // Optional — omitted when the frontmatter declares none.
197
- must_read_if: z3.string().optional()
206
+ must_read_if: z3.string().optional(),
207
+ // TASK-003 (impact-map MVP): the entry's impact list, forwarded so the narrow
208
+ // PreToolUse hint can surface the consequences of ignoring this knowledge when
209
+ // editing a matching relevance path. Optional — omitted when none declared.
210
+ impact: z3.array(z3.string()).optional()
198
211
  });
199
212
  var planContextHintOutputSchema = z3.object({
200
213
  version: z3.literal(1),
@@ -242,8 +255,8 @@ var knowledgeSectionsOutputSchema = z3.object({
242
255
  diagnostics: z3.array(
243
256
  // v2.0.0-rc.23 TASK-013 (F8b): `missing_section` was removed alongside the
244
257
  // A-set enum. `missing_knowledge_metadata` stays as the warn-level signal
245
- // for un-migrated v1.x entries (no knowledge_type AND no knowledge_layer
246
- // in frontmatter). Does NOT block selection.
258
+ // for un-migrated v1.x entries (no knowledge_type in frontmatter). Does NOT
259
+ // block selection.
247
260
  z3.object({
248
261
  code: z3.enum(["missing_knowledge_metadata", "unresolved_selected_id"]),
249
262
  severity: z3.literal("warn"),
@@ -313,7 +326,33 @@ var _recallEntrySchema = z3.object({
313
326
  store: z3.object({ alias: z3.string() }).optional(),
314
327
  // true when this entry's body is ALSO injected at SessionStart (broad
315
328
  // model/guideline "ALWAYS-ACTIVE") — skip the Read, it is already in context.
316
- body_in_context: z3.boolean().optional()
329
+ body_in_context: z3.boolean().optional(),
330
+ // P1 recall-observability: the fused relevance score this entry scored during
331
+ // the plan-context sort (was computed internally but dropped before this wave).
332
+ // Optional + additive — backward-compatible. MUST be declared here or zod
333
+ // .strip() silently drops it at the MCP boundary (KT-PIT-0005).
334
+ score: z3.number().optional(),
335
+ // P1 recall-observability: numbers-only decomposition of `score` into its
336
+ // weighted signal contributions. NEVER carries body/description text — preserves
337
+ // the lean read_path contract (KT-DEC-0019 / KT-GLD-0005). bm25_rank/vector_rank
338
+ // are reserved for a later RRF wave (declared so the wire never strips them).
339
+ score_breakdown: z3.object({
340
+ final: z3.number(),
341
+ bm25: z3.number().optional(),
342
+ bm25_rank: z3.number().optional(),
343
+ vector: z3.number().optional(),
344
+ vector_rank: z3.number().optional(),
345
+ salience: z3.number(),
346
+ recency: z3.number(),
347
+ locality: z3.number(),
348
+ // BORROW-008 proximity boost — MUST be declared or zod .strip() drops it at
349
+ // the MCP boundary (KT-PIT-0005), desyncing wire `final` from its components.
350
+ proximity: z3.number(),
351
+ // PLN-004 F1 credibility content-age decay MULTIPLIER factor — optional
352
+ // (only present once the multiplier is wired). MUST be declared or zod
353
+ // .strip() drops it at the MCP boundary (KT-PIT-0005).
354
+ credibility: z3.number().optional()
355
+ }).optional()
317
356
  });
318
357
  var recallOutputSchema = z3.object({
319
358
  revision_hash: z3.string(),
@@ -642,7 +681,19 @@ var _fabReviewModifyChangesSchema = z3.object({
642
681
  // edges via fab_recall and sends the merged set. Absent this field the modify
643
682
  // path silently dropped `related` via zod .strip() (KT-PIT-0005 recurrence),
644
683
  // leaving the only programmatic related-write path non-functional.
645
- related: z3.array(z3.string()).optional()
684
+ related: z3.array(z3.string()).optional(),
685
+ // rc.9 (2026-07-06): discovery-signal scalar patches — must_read_if triggers
686
+ // Reference-type entry surfacing; intent_clues drives the AI's "should I Read
687
+ // the body?" judgment; impact enumerates consequence prose surfaced in the
688
+ // BM25F body slot. Before rc.9 these three fields were undeclared here, so
689
+ // fab_review modify silently .strip()'d them (KT-PIT-0005 recurrence) and the
690
+ // only path to fix a bad-shape must_read_if / missing intent_clues was direct
691
+ // Edit — bypassing the skill audit trail. All three are REPLACE semantics
692
+ // (mirror tags/related). must_read_if is a scalar string; intent_clues +
693
+ // impact are flow-arrays.
694
+ must_read_if: z3.string().optional(),
695
+ intent_clues: z3.array(z3.string()).optional(),
696
+ impact: z3.array(z3.string()).optional()
646
697
  });
647
698
  var FabReviewInputSchema = z3.discriminatedUnion("action", [
648
699
  z3.object({
@@ -1073,8 +1124,6 @@ var KnowledgeEntryFrontmatterSchema = z3.object({
1073
1124
  // draft | verified | proven
1074
1125
  layer: LayerSchema,
1075
1126
  // personal | team
1076
- layer_reason: z3.string().optional(),
1077
- // why this layer (for ambiguous cases)
1078
1127
  created_at: z3.string()
1079
1128
  // ISO 8601 timestamp
1080
1129
  // Note: 'tags' and other fields can be added later but core schema is these 6