@fenglimg/fabric-shared 1.8.0-rc.3 → 2.0.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.
@@ -6,20 +6,38 @@ var structuredWarningSchema = z.object({
6
6
  line: z.number().optional(),
7
7
  action_hint: z.string()
8
8
  });
9
+ var _knowledgeTypeEnum = z.enum(["model", "decision", "guideline", "pitfall", "process"]);
10
+ var _maturityEnum = z.enum(["draft", "verified", "proven"]);
11
+ var _layerEnum = z.enum(["personal", "team"]);
9
12
  var _ruleDescriptionSchema = z.object({
10
13
  summary: z.string(),
11
14
  intent_clues: z.array(z.string()),
12
15
  tech_stack: z.array(z.string()),
13
16
  impact: z.array(z.string()),
14
17
  must_read_if: z.string(),
15
- entities: z.array(z.string()).optional()
18
+ entities: z.array(z.string()).optional(),
19
+ // v2.0: optional knowledge-entry fields. Absent for v1.x rules; present for
20
+ // entries that declare frontmatter `id/type/maturity/layer`.
21
+ id: z.string().optional(),
22
+ knowledge_type: _knowledgeTypeEnum.optional(),
23
+ maturity: _maturityEnum.optional(),
24
+ knowledge_layer: _layerEnum.optional(),
25
+ layer_reason: z.string().optional(),
26
+ created_at: z.string().optional()
16
27
  });
17
28
  var _descriptionIndexItemSchema = z.object({
18
29
  stable_id: z.string(),
19
30
  level: z.enum(["L0", "L1", "L2"]),
20
31
  required: z.boolean(),
21
32
  selectable: z.boolean(),
22
- description: _ruleDescriptionSchema
33
+ description: _ruleDescriptionSchema,
34
+ // v2.0: top-level knowledge surface for client-side filtering. Mirrors
35
+ // description.* — exposed here so MCP clients can filter without reaching
36
+ // into the nested payload.
37
+ type: _knowledgeTypeEnum.optional(),
38
+ maturity: _maturityEnum.optional(),
39
+ layer: _layerEnum.optional(),
40
+ layer_reason: z.string().optional()
23
41
  });
24
42
  var _requirementProfileSchema = z.object({
25
43
  target_path: z.string(),
@@ -44,7 +62,10 @@ var planContextInputSchema = z.object({
44
62
  detected_entities: z.record(z.array(z.string())).optional().describe("Optional path-keyed detected entities for the requirement profile"),
45
63
  client_hash: z.string().optional().describe("Revision hash from a prior fab_plan_context response; enables stale detection"),
46
64
  correlation_id: z.string().optional().describe("Optional caller-provided correlation id for Event Ledger records"),
47
- session_id: z.string().optional().describe("Optional caller-provided session id for Event Ledger records")
65
+ session_id: z.string().optional().describe("Optional caller-provided session id for Event Ledger records"),
66
+ include_deprecated: z.boolean().optional().describe(
67
+ "When true, include description_index entries with maturity='deprecated'. Defaults to false (deprecated entries hidden). Note: 'deprecated' is reserved future state \u2014 today this filter is a no-op until MaturitySchema is widened."
68
+ )
48
69
  });
49
70
  var planContextOutputSchema = z.object({
50
71
  revision_hash: z.string(),
@@ -134,13 +155,23 @@ var ruleSectionsOutputSchema = z.object({
134
155
  })
135
156
  ),
136
157
  diagnostics: z.array(
137
- z.object({
138
- code: z.literal("missing_section"),
139
- severity: z.literal("warn"),
140
- stable_id: z.string(),
141
- section: z.enum(RULE_SECTION_NAMES_TUPLE),
142
- message: z.string()
143
- })
158
+ z.discriminatedUnion("code", [
159
+ z.object({
160
+ code: z.literal("missing_section"),
161
+ severity: z.literal("warn"),
162
+ stable_id: z.string(),
163
+ section: z.enum(RULE_SECTION_NAMES_TUPLE),
164
+ message: z.string()
165
+ }),
166
+ // v2.0: warn-level diagnostic for un-migrated v1.x entries (no
167
+ // knowledge_type and no knowledge_layer). Does NOT block selection.
168
+ z.object({
169
+ code: z.literal("missing_knowledge_metadata"),
170
+ severity: z.literal("warn"),
171
+ stable_id: z.string(),
172
+ message: z.string()
173
+ })
174
+ ])
144
175
  ),
145
176
  warnings: z.array(structuredWarningSchema).optional()
146
177
  });
@@ -202,6 +233,58 @@ var annotateIntentRequestSchema = z.object({
202
233
  ledger_entry_id: z.string().min(1),
203
234
  annotation: z.string().trim().min(1)
204
235
  });
236
+ var KnowledgeTypeSchema = z.enum([
237
+ "model",
238
+ // entities, data structures, relationships
239
+ "decision",
240
+ // architectural/technical choices with rationale
241
+ "guideline",
242
+ // recommended practices (recommend) or anti-patterns (avoid)
243
+ "pitfall",
244
+ // known risks, failure modes, troubleshooting
245
+ "process"
246
+ // workflows, state machines, operational steps
247
+ ]);
248
+ var MaturitySchema = z.enum(["draft", "verified", "proven"]);
249
+ var LayerSchema = z.enum(["personal", "team"]);
250
+ var StableIdSchema = z.string().regex(/^K[PT]-(MOD|DEC|GLD|PIT|PRO)-\d{4,}$/);
251
+ var KnowledgeEntryFrontmatterSchema = z.object({
252
+ id: StableIdSchema,
253
+ // e.g., "KT-DEC-0042"
254
+ type: KnowledgeTypeSchema,
255
+ // one of 5 types
256
+ maturity: MaturitySchema,
257
+ // draft | verified | proven
258
+ layer: LayerSchema,
259
+ // personal | team
260
+ layer_reason: z.string().optional(),
261
+ // why this layer (for ambiguous cases)
262
+ created_at: z.string()
263
+ // ISO 8601 timestamp
264
+ // Note: 'tags' and other fields can be added later but core schema is these 6
265
+ });
266
+ var KNOWLEDGE_TYPE_CODES = {
267
+ model: "MOD",
268
+ decision: "DEC",
269
+ guideline: "GLD",
270
+ pitfall: "PIT",
271
+ process: "PRO"
272
+ };
273
+ function formatKnowledgeId(layer, type, counter) {
274
+ const layerPrefix = layer === "personal" ? "KP" : "KT";
275
+ const typeCode = KNOWLEDGE_TYPE_CODES[type];
276
+ return `${layerPrefix}-${typeCode}-${String(counter).padStart(4, "0")}`;
277
+ }
278
+ function parseKnowledgeId(id) {
279
+ const match = id.match(/^(KP|KT)-(MOD|DEC|GLD|PIT|PRO)-(\d+)$/);
280
+ if (!match) return null;
281
+ const layer = match[1] === "KP" ? "personal" : "team";
282
+ const typeCode = match[2];
283
+ const entry = Object.entries(KNOWLEDGE_TYPE_CODES).find(([, code]) => code === typeCode);
284
+ if (!entry) return null;
285
+ const type = entry[0];
286
+ return { layer, type, counter: parseInt(match[3], 10) };
287
+ }
205
288
 
206
289
  export {
207
290
  structuredWarningSchema,
@@ -219,5 +302,13 @@ export {
219
302
  historyStateQuerySchema,
220
303
  humanLockApproveRequestSchema,
221
304
  humanLockFileParamsSchema,
222
- annotateIntentRequestSchema
305
+ annotateIntentRequestSchema,
306
+ KnowledgeTypeSchema,
307
+ MaturitySchema,
308
+ LayerSchema,
309
+ StableIdSchema,
310
+ KnowledgeEntryFrontmatterSchema,
311
+ KNOWLEDGE_TYPE_CODES,
312
+ formatKnowledgeId,
313
+ parseKnowledgeId
223
314
  };
@@ -165,9 +165,6 @@ var enMessages = {
165
165
  "cli.init.capabilities.follow-up.install": "install client assets",
166
166
  "cli.init.capabilities.follow-up.manual": "manual step required",
167
167
  "cli.init.next-step.message": "run fab hooks install to add the Day 4 pre-commit pipeline.",
168
- "cli.init.reason-message.claude-body": ".fabric/forensic.json is ready; use the fabric-init skill to finish internal Fabric initialization.",
169
- "cli.init.reason-message.codex-body": ".fabric/forensic.json is ready; continue with the repo skill at .codex/skills/fabric-init/SKILL.md and enable features.codex_hooks = true for Codex hooks.",
170
- "cli.init.reason-message.multi-body": ".fabric/forensic.json is ready; continue in your installed client flow: Claude can use fabric-init, and Codex can use .codex/skills/fabric-init/SKILL.md with features.codex_hooks = true.",
171
168
  "cli.init.reason-message.installable-body": ".fabric/forensic.json is ready; some detected clients support Fabric follow-up but still need client assets installed.",
172
169
  "cli.init.reason-message.manual-body": ".fabric/forensic.json is ready; some detected clients still need manual follow-up because no Fabric skill is installed for them yet.",
173
170
  "cli.init.codex-hooks.created": "{label} {path} with Codex hooks config (requires features.codex_hooks = true).",
@@ -195,6 +192,9 @@ var enMessages = {
195
192
  "cli.scan.args.target.description": "Target absolute path. Defaults to CLI arg, EXTERNAL_FIXTURE_PATH, fabric.config.json, then cwd.",
196
193
  "cli.scan.args.debug.description": "Print detection evidence in formatted output.",
197
194
  "cli.scan.args.json.description": "Print the diagnostic report as JSON.",
195
+ "cli.scan.error.missing-forensic": "forensic.json not found at {path}; run `fabric init` first to produce the deterministic project snapshot.",
196
+ "cli.scan.summary.created": "Wrote {count} knowledge entries to .fabric/knowledge/.",
197
+ "cli.scan.summary.skipped": "No changes detected; {count} entries already up-to-date.",
198
198
  "cli.scan.report.title": "Fabric scan report",
199
199
  "cli.scan.report.target": "Target",
200
200
  "cli.scan.report.framework": "Framework",
@@ -600,9 +600,6 @@ var zhCNMessages = {
600
600
  "cli.init.capabilities.follow-up.install": "\u5B89\u88C5\u5BA2\u6237\u7AEF\u8D44\u4EA7",
601
601
  "cli.init.capabilities.follow-up.manual": "\u9700\u8981\u624B\u52A8\u540E\u7EED\u5904\u7406",
602
602
  "cli.init.next-step.message": "\u8FD0\u884C fab hooks install \u4EE5\u6DFB\u52A0\u7B2C 4 \u5929\u7684 pre-commit \u6D41\u6C34\u7EBF\u3002",
603
- "cli.init.reason-message.claude-body": ".fabric/forensic.json \u5DF2\u5C31\u7EEA\uFF1B\u8BF7\u4F7F\u7528 fabric-init skill \u5B8C\u6210 Fabric \u5185\u90E8\u521D\u59CB\u5316\u3002",
604
- "cli.init.reason-message.codex-body": ".fabric/forensic.json \u5DF2\u5C31\u7EEA\uFF1B\u8BF7\u7EE7\u7EED\u4F7F\u7528\u4ED3\u5E93\u5185\u7684 .codex/skills/fabric-init/SKILL.md\uFF0C\u5E76\u4E3A Codex hooks \u542F\u7528 features.codex_hooks = true\u3002",
605
- "cli.init.reason-message.multi-body": ".fabric/forensic.json \u5DF2\u5C31\u7EEA\uFF1B\u8BF7\u6309\u5DF2\u5B89\u88C5\u5BA2\u6237\u7AEF\u7EE7\u7EED\u540E\u7EED\u6D41\u7A0B\uFF1AClaude \u4F7F\u7528 fabric-init\uFF0CCodex \u4F7F\u7528 .codex/skills/fabric-init/SKILL.md\uFF0C\u5E76\u542F\u7528 features.codex_hooks = true\u3002",
606
603
  "cli.init.reason-message.installable-body": ".fabric/forensic.json \u5DF2\u5C31\u7EEA\uFF1B\u90E8\u5206\u5DF2\u68C0\u6D4B\u5230\u7684\u5BA2\u6237\u7AEF\u5DF2\u652F\u6301 Fabric \u540E\u7EED\u63A5\u529B\uFF0C\u4F46\u4ECD\u9700\u5B89\u88C5\u5BA2\u6237\u7AEF\u8D44\u4EA7\u3002",
607
604
  "cli.init.reason-message.manual-body": ".fabric/forensic.json \u5DF2\u5C31\u7EEA\uFF1B\u90E8\u5206\u5DF2\u68C0\u6D4B\u5230\u7684\u5BA2\u6237\u7AEF\u5C1A\u672A\u5B89\u88C5 Fabric skill\uFF0C\u9700\u8981\u624B\u52A8\u5B8C\u6210\u540E\u7EED\u521D\u59CB\u5316\u3002",
608
605
  "cli.init.codex-hooks.created": "{label} {path}\uFF0C\u5E76\u5199\u5165 Codex hooks \u914D\u7F6E\uFF08\u9700\u542F\u7528 features.codex_hooks = true\uFF09\u3002",
@@ -630,6 +627,9 @@ var zhCNMessages = {
630
627
  "cli.scan.args.target.description": "\u76EE\u6807\u7EDD\u5BF9\u8DEF\u5F84\u3002\u9ED8\u8BA4\u4F9D\u6B21\u4F7F\u7528 CLI \u53C2\u6570\u3001EXTERNAL_FIXTURE_PATH\u3001fabric.config.json\u3001\u5F53\u524D\u76EE\u5F55\u3002",
631
628
  "cli.scan.args.debug.description": "\u4EE5\u683C\u5F0F\u5316\u8F93\u51FA\u6253\u5370\u68C0\u6D4B\u8BC1\u636E\u3002",
632
629
  "cli.scan.args.json.description": "\u4EE5 JSON \u683C\u5F0F\u8F93\u51FA\u8BCA\u65AD\u62A5\u544A\u3002",
630
+ "cli.scan.error.missing-forensic": "\u672A\u627E\u5230 forensic.json\uFF08\u8DEF\u5F84 {path}\uFF09\uFF1B\u8BF7\u5148\u8FD0\u884C `fabric init` \u751F\u6210\u9879\u76EE\u5FEB\u7167\u3002",
631
+ "cli.scan.summary.created": "\u5DF2\u5199\u5165 {count} \u6761\u77E5\u8BC6\u6761\u76EE\u81F3 .fabric/knowledge/\u3002",
632
+ "cli.scan.summary.skipped": "\u65E0\u5DEE\u5F02\uFF1B{count} \u6761\u5DF2\u5B58\u5728\u7684\u6761\u76EE\u4FDD\u6301\u4E0D\u53D8\u3002",
633
633
  "cli.scan.report.title": "Fabric \u626B\u63CF\u62A5\u544A",
634
634
  "cli.scan.report.target": "\u76EE\u6807",
635
635
  "cli.scan.report.framework": "\u6846\u67B6",
@@ -6,7 +6,7 @@ import {
6
6
  enMessages,
7
7
  normalizeLocale,
8
8
  zhCNMessages
9
- } from "../chunk-FEEWLYO3.js";
9
+ } from "../chunk-KHIM6MWS.js";
10
10
  export {
11
11
  PROTECTED_TOKENS,
12
12
  createTranslator,